I'm trying to build one of my first php procedure but I'm struggling on an apparently stupid issue and I need your help:
I need to load and modify an xml file and then I have to send via curl
here it is what I've done so far:
$userID='John';
$Action="Read";
$Quarter="2";
$xml=simplexml_load_file("test/xml/testxml.xml") or die("Error: Cannot create object");
$xml->User->UserID=$userID;
$xml->Action=$Action;
$xml->Quarter=$Quarter;
$responseXml = sendHttpRequest($xml);
the problem, I suppose, is that sendHttpRequest requires $xml to be a string, while in my example it is an object I'm quite sure about this since if I build the xml as a string..
$xml = '<?xml version="1.0" encoding="utf-8" ?>';
$xml .= '<Request>';
$xml .= "<User><UserID>$userID</userID></User>";
$xml .= "<Action>$Action</Action>";
$xml .= "<Quarter>$Quarter</Quarter>";
$xml .= '</Request>';
sendHttpRequest function works.
Therefore, hwo to transform $xml into a string?
I've seen some example using
(string) $xml-> ....
but these examples extract a node of the xml as string, while I need it fully.
Thanks Joe