0

I can not for the life of me figure out how to keep the formatting of XML in a string, even when echoing the string of $data_string I get the XML stripped out and only the values remain.

Then I need to be able to do a CURL request via PHP with that string, I'm not sure if I have the right setup for that though.

Code:

$data_string = '<test><name>John Doe</name><age>22</age><city>seattle</age></test>';

$curl = curl_init($baseUrl);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_POST, true);
curl_setopt($curl, CURLOPT_POSTFIELDS, "xmlRequest=" . $data_string);
curl_setopt($curl, CURLOPT_HTTPHEADER, array(
    "Content-Length: " . strlen($data_string),
    "X-DocuSign-Authentication: $header",
    "Content-Type: text/xml",
    "Accept: text/xml" )
);
$response = curl_exec($curl);

Test:

echo $data_string;

Result:

John Doe22seattle
2
  • "I can not for the life of me" :)))))) Commented Apr 23, 2014 at 22:14
  • try checking the source code of the page you're in, normally CTRL+U Commented Apr 23, 2014 at 22:15

1 Answer 1

1

You should make sure that the page you are echoing is ALSO using the MIME type text/xml.

Another way i can think of, is to escape the html characters using htmlentities()

Sign up to request clarification or add additional context in comments.

2 Comments

htmlentities seemed to work, is there a way to pretty print it with that?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.