Get XML results as string

aszmhodeus

New Member
I have the following code which generates XML:\[code\]$dom = new DomDocument('1.0');...snip adding elements to document...$xmlout = $dom->saveXML();$api = "myapi.com/myservice?". trim($xmlout);\[/code\]The problem is that if I look at the actual value of \[code\]$api\[/code\] it looks like \[code\]"myapi.com/myservice?"<xml-structure>\[/code\]instead of \[code\]"myapi.com/myservice?<xml-structure>"\[/code\]when I print out $api using \[code\]print_r();\[/code\] and I suspect that this is interfering with actually calling the api, since the url is incorrect. My suspicion is that \[code\]$dom->saveXML()\[/code\] is returning an associative array, and not, in fact, a string - and this is implied by the fact that if I echo $xmlout, it only prints the values of the various nodes, but not the nodes themselves.What is the simplest way to get a string representation of the XML which includes the names of all the nodes, etc?
 
Back
Top