doug007 Posted April 15, 2009 Share Posted April 15, 2009 Guys, I have the below cURL loading an xml document that i like to post to another server, so to test this i actually posting it to a test page on my server. the problem is when i try to see what was posted using print_r i only see the root element <book> XML: <?xml version="1.0"?> <library> <book isbn="0345342968"> <title>Fahrenheit 451</title> <title>Fahrenheit 55</title> <author>R. Bradbury</author> <publisher>Del Rey</publisher> <date> <day>12</day> <month>12</month> <year>2009</year> </date> </book> </library> cURL (PHP) $library = simplexml_load_file('library.xml', null, true); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, 'http://localhost/practice/orange/test.php'); curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt($ch, CURLOPT_TIMEOUT, 4); curl_setopt($ch, CURLOPT_POSTFIELDS, $library); curl_setopt($ch, CURLOPT_HTTPHEADER, array('Connection: close')); /** * Execute the request and also time the transaction */ $start = array_sum(explode(' ', microtime())); $result = curl_exec($ch); $stop = array_sum(explode(' ', microtime())); $totalTime = $stop - $start; /** * Check for errors */ if ( curl_errno($ch) ) { $result = 'cURL ERROR -> ' . curl_errno($ch) . ': ' . curl_error($ch); } else { $returnCode = (int)curl_getinfo($ch, CURLINFO_HTTP_CODE); switch($returnCode){ case 200: break; default: $result = 'HTTP ERROR -> ' . $returnCode; break; } } /** * Close the handle */ curl_close($ch); /** * Output the results and time */ echo 'Total time for request: ' . $totalTime . "\n"; echo $result; /** * Exit the script */ exit(0); Link to comment https://forums.phpfreaks.com/topic/154177-xml/ Share on other sites More sharing options...
okamosy Posted April 15, 2009 Share Posted April 15, 2009 What happens when you use var_dump($library) instead of print_r? Link to comment https://forums.phpfreaks.com/topic/154177-xml/#findComment-810736 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.