我試圖檢索使用curl使用此代碼從一個API數據:使用數據
$xml_data = '<name>foobar%</name>';
$URL = "http://www.example.com/api/foobar.xml";
$ch = curl_init($URL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: text/xml'));
curl_setopt($ch, CURLOPT_POSTFIELDS, "$xml_data");
$output = curl_exec($ch);
curl_close($ch);
當我執行這個PHP腳本,一切運作良好,並返回正確的XML數據在我的瀏覽器中。我的問題是,我如何解析這些數據?
(如果你建議我做使用不同的方法,捲曲,整個事情,請隨時告訴我)
參見[PHP的最佳XML分析器(http://stackoverflow.com/q/188414/693207)查看解析器列表。 – 2011-12-27 09:52:42