Reputation: 4441
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
Upvotes: 0
Views: 141
Reputation: 29032
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()
Upvotes: 1