lightlydone Posted June 16, 2011 Share Posted June 16, 2011 Hi, I'm posting an XML string using curl and trying to read response using DOMDocument but the returned array is empty. Can anyone help with this? curl_setopt($ch, CURLOPT_HEADER, 0); curl_setopt($ch, CURLOPT_RETURNTRANSFER, '1'); curl_setopt($ch, CURLOPT_POST, true); curl_setopt($ch, CURLOPT_POSTFIELDS, $leadXML); $leadResult = curl_exec($ch); curl_close($ch); $xmlDoc = new DOMDocument(); $xmlDoc ->load($leadResult); $x = $xmlDoc->getElementsByTagName("result"); $results = array(); foreach($x as $item){ $res = array(); if($item->childNodes->length) { foreach($item->childNodes as $i){ $res[$i->nodeName] = $i->nodeValue; } } $results[] = $res; } var_dump($results); Quote Link to comment https://forums.phpfreaks.com/topic/239529-reading-xml-response/ Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.