如何获得xml的链接列表


How to get a list of links to the 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;
}   

我想您想要一个所有"loc"元素的列表。

$simpleObj = simplexml_load_string($xml);
$loc = $simpleObj->xpath('//loc');
foreach($loc as $url){
    echo $url;
}