I have tried following the advice in this thread, but I still seem to be having trouble getting a usable array from a raw XML CURL response (actually I just want a couple of bits of data from the output)...
Here is my code:
echo "Curl started...<br />\n\n";
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,$target_url);
curl_setopt($ch, CURLOPT_POST,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $post);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HEADER, false);
$response=curl_exec ($ch);
curl_close ($ch);
$response_xml = simplexml_load_string($response);
$system_ref = $response_xml->OBJECT->SYSTEMREFERENCE;
echo "Curl finished...<br />\n\n";
print_r($response_xml);
Here is the raw response which is fed into $response :
<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE IAD.IF.OBJECTRESPONSE SYSTEM "http://www.someplace.com/dtd/IADIF-objectresponse.dtd">
<IAD.IF.OBJECTRESPONSE>
<HEAD>
<PARTNER>somepartner</PARTNER>
<UPLOAD_REFERENCE/>
<IMPORTTYPE>STORING AD</IMPORTTYPE>
<PROCESSEDTIME>2013.05.17 11:29:29</PROCESSEDTIME>
<SOURCE>originalsource_342423424.xml</SOURCE>
</HEAD>
<OBJECT STATUS="ok">
<ORDERNO/>
<VERSION></VERSION>
<USERREFERENCE></USERREFERENCE>
<SYSTEMREFERENCE>34324242</SYSTEMREFERENCE>
</OBJECT>
</IAD.IF.OBJECTRESPONSE>
So, if I echo or print_r $response, I get a raw string output... but if I print_r $response_xml (as in the example above) , I don't seem to get anything.
For the moment, my goal is to simply get the SYSTEMREFERENCE data into a variable...
Can anyone please advise?
---------
PS. Been lurking a while but this seems to be my first question on Stackoverflow, so please go easy on me. Hope I've done it right. :)