Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7823677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 2, 20262026-06-02T08:20:05+00:00 2026-06-02T08:20:05+00:00

I am posting an XML file to a server using curl. Everthing works perfectly

  • 0

I am posting an XML file to a server using curl. Everthing works perfectly but I am not sure how to handle the response best way. I would like to parse it with simpleXML. With this request:

$ch = curl_init(); 

curl_setopt($ch, CURLOPT_VERBOSE, 1); 
curl_setopt($ch, CURLOPT_URL, $url); 
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); 
curl_setopt($ch, CURLOPT_HTTPHEADER, Array("Content-Type: text/xml"));
curl_setopt($ch, CURLOPT_HEADER, 1);
curl_setopt($ch, CURLOPT_TIMEOUT, 40); 
curl_setopt($ch, CURLOPT_POSTFIELDS, $XPost);
curl_setopt($ch, CURLOPT_POST, 1);

$data = curl_exec($ch); 

if(curl_errno($ch))
print curl_error($ch);
else
print_r($data);
curl_close($ch);

I am getting this as response-string (browser source view)

HTTP/1.1 200 OK
Server: Apache-Coyote/1.1
Expires: Sat, 6 May 1995 12:00:00 GMT
Cache-Control: no-store, no-cache, must-revalidate
Cache-Control: post-check=0, pre-check=0
Pragma: no-cache
Set-Cookie: JSESSIONID=5FD40C8D8F5EDC85E57AF39E877BE564; Path=/upp/; Secure; HttpOnly
Content-Type: text/xml;charset=UTF-8
Content-Length: 829
Date: Sun, 22 Apr 2012 08:59:10 GMT

<?xml version='1.0' encoding='UTF-8'?>
<authorizationService version='1'>
<body merchantId='635634545' status='accepted'>
<transaction refno='1234987' trxStatus='response'>
  <request>
    <amount>2000</amount>
    <currency>USD</currency>
  </request>
  <response>
    <responseCode>01</responseCode>
    <responseMessage>Authorized</responseMessage>
  </response>
</transaction>

How do I correctly parse $data with simpleXML.I mean getting rid of the header part?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-02T08:20:06+00:00Added an answer on June 2, 2026 at 8:20 am

    If you don’t need the header, set CURLOPT_HEADER to false.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to parse an xml file using XmlReader but although I am
I am using Firefox to read XML files, but it is not rendering the
first time posting here. I'm using a loop to create 3 buttons, but my
I am trying to create a dynamic menu by reading an XML file using
While I am posting XML content from one server to other server, it is
A remote server is POSTing XML to my server via RPC. I can see
I am attempting to POST against a vendor's server using PHP 5.2 with cURL.
Before posting this I've read through but I'm still not clear on how to
I'm afraid I've not got much experience with posting documents (e.g. XML) over web-servers,
I am trying to generate xml file as a background task using resque gem

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.