2013-03-08 114 views
-1

XML文件:如何獲取xml鏈接列表?

<urlset> 
    <url> 
     <loc>http://example.com/.../</loc> 
     <lastmod>0000-00-00</lastmod> 
     <priority>0</priority> 
    </url> 
    <url> 
     <loc>http://example.com/...</loc> 
     <lastmod>0000-00-00</lastmod> 
     <priority>0</priority> 
    </url> 
</urlset> 

如何獲得鏈接到XML列表? (谷歌翻譯)

foreach ($html->find('?????') as $element) { 
    echo $element->src; 
} 
+0

可能DUP:http://stackoverflow.com/questions/3577641/how-to-parse-and-process-html-xml-with-php/3577662#3577662 – 2013-03-08 13:54:33

+0

要將XML ???所以你想解析XML文件?或者你嘗試了什麼。 – Stony 2013-03-08 13:58:38

回答

0

我假設你想要一個所有「loc」元素的列表。

$simpleObj = simplexml_load_string($xml); 
$loc = $simpleObj->xpath('//loc'); 

foreach($loc as $url){ 
    echo $url; 
}