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

  • Home
  • SEARCH
  • 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 511149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T07:11:13+00:00 2026-05-13T07:11:13+00:00

Scenario: Sending XML, generated using php, via cURL to an external server for parsing.

  • 0

Scenario:
Sending XML, generated using php, via cURL to an external server for parsing.

Problem:
The XML contains tag attributes which cause problems when being sent using cURL

Code:

$generated_xml =
-- NOTE: NOT THE SYNTAX USED IN THE CODE, SPLIT FOR EASE OF READING --
"<xconnect>
    <report>
        <id>contact_get</id>
        <input name='email'><![CDATA[EMAIL_CAPTURED_FROM_INPUT]]></input>
        <input name='id'></input>
    </report>
</xconnect>";

$aCurlHeaders = array ("Content-Type: text/xml");
$hCurl = curl_init();

-- NOTE: HTTPHEADER OPTION FAILS (page returns 'no xml sent') --

curl_setopt($hCurl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($hCurl, CURLOPT_POST, true);
curl_setopt($hCurl, CURLOPT_CONNECTTIMEOUT, 120);
//curl_setopt($hCurl, CURLOPT_HTTPHEADER, array("Content-Type: text/xml"));
curl_setopt($hCurl, CURLOPT_URL, "SITE_URL");
curl_setopt($hCurl, CURLOPT_POSTFIELDS, "XMLDOC=$generated_xml");

$sResp = curl_exec($hCurl);

curl_close($hCurl);

if($sResp){ echo $sResp; }

Further details:

I don’t know a huge amount about cURL

When sent to the page which parses the XML via cURL, it returns ‘XML document failed parsing’, however when using their testing form, which submits directly to the server via a POST form, it works fine and returns the correct data.

The problem is linked to the attributes of the <input> tags, removing them allows the xml to parse on the server properly, but returns empty as the attributes are required to retrieve the data from the server.

I have no access to the parsing page, which dictates the XML, though have a contact there who may be able to change the coding to not require attributes, though I would have thought it would be possible to do this without making changes.

Questions:

Why does sending HTTPHEADER cause the parser to think the info sent isn’t XML, is it to do with the way I’m sending the XML?

Is it possible to block the XML from parsing in the php (if that’s part of the problem)

I’ve seen examples of using attributes in cURL before so what is it about this

Thanks:

Thanks

  • 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-05-13T07:11:14+00:00Added an answer on May 13, 2026 at 7:11 am

    Try sending your XML data as normal POST string don’t mention header.
    and before sending use $generated_xml = urlencode($generated_xml);.

    and on the external server side use $generated_xml = urldecode($generated_xml);
    and parse the data.

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

Sidebar

Ask A Question

Stats

  • Questions 274k
  • Answers 274k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Thanks everyone. The case that prompted this question ended well,… May 13, 2026 at 2:27 pm
  • Editorial Team
    Editorial Team added an answer If you create a closure for it, you won't have… May 13, 2026 at 2:27 pm
  • Editorial Team
    Editorial Team added an answer Through a bit of thinking real hard and Googling, I… May 13, 2026 at 2:27 pm

Related Questions

I have an XML parser that crashes on incomplete XML data. So XML data
I've got a web app that sends a request to a WCF service. The
Scenario: An interactive CLI Python program, that is in need for a password. That
Scenario. I have a client with two network connections to a server. One connection
Imagine having the following scenario: You need to create a system where the Back

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.