我使用下面的函數如何遍歷XML在PHP
function file_get_contents_curl($url) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_AUTOREFERER, TRUE);
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, TRUE);
$data = curl_exec($ch);
curl_close($ch);
return $data;
}
$myTestingUrl = file_get_contents_curl("myUrl");
我運行的功能我有
$myTestingUrl =
<?xml version="1.0" encoding="UTF-8"?>
<map>
<entry key="keyName">
<entry key="ActionUrl">http://www.my_actionUrl.com/</entry>
</entry>
</map>
能否請你告訴我,我怎麼可以遍歷$ myTestingUrl拿到後入門鍵「ActionUrl」(http://www.my_actionUrl.com/)中的一個變量在php中的內容?
謝謝!
可能重複[在PHP中遍歷XML](http://stackoverflow.com/questions/6301084/traversing-xml-in-php) – ajreal