Extract Links from a sitemap(xml)

Posted by Akshat Mittal on Super User See other posts from Super User or by Akshat Mittal
Published on 2012-08-27T11:11:58Z Indexed on 2012/08/28 9:41 UTC
Read the original article Hit count: 383

Filed under:
|
|
|

Lets say I have a sitemap.xml file with this data:

<url>
<loc>http://domain.com/pag1</loc>
<lastmod>2012-08-25</lastmod>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>http://domain.com/pag2</loc>
<lastmod>2012-08-25</lastmod>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>
<url>
<loc>http://domain.com/pag3</loc>
<lastmod>2012-08-25</lastmod>
<changefreq>weekly</changefreq>
<priority>0.9</priority>
</url>

I want to extract all the locations from it (data between <loc> and </loc>).

Sample output be like:

http://domain.com/pag1
http://domain.com/pag2
http://domain.com/pag3

How to do this?

© Super User or respective owner

Related posts about url

Related posts about Xml