Axcelcius Posted October 19, 2007 Share Posted October 19, 2007 I am trying to work with a sitemap and be able to add and delete URLs. So I need to be able to search out URL sections like below using the URL link as the identifier for the section of code. What expression would I use to find the bottom section of code in the sitemap? It would have to match the URL exactly. <url> <loc>http://www.example.com/catalog?item=73&desc=vacation_new_zealand</loc> <lastmod>2004-12-23</lastmod> <changefreq>weekly</changefreq> </url> sitemap.xml <?xml version="1.0" encoding="UTF-8"?> <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9"> <url> <loc>http://www.example.com/</loc> <lastmod>2005-01-01</lastmod> <changefreq>monthly</changefreq> <priority>0.8</priority> </url> <url> <loc>http://www.example.com/catalog?item=12&desc=vacation_hawaii</loc> <changefreq>weekly</changefreq> </url> <url> <loc>http://www.example.com/catalog?item=73&desc=vacation_new_zealand</loc> <lastmod>2004-12-23</lastmod> <changefreq>weekly</changefreq> </url> <url> <loc>http://www.example.com/catalog?item=74&desc=vacation_newfoundland</loc> <lastmod>2004-12-23T18:00:15+00:00</lastmod> <priority>0.3</priority> </url> <url> <loc>http://www.example.com/catalog?item=83&desc=vacation_usa</loc> <lastmod>2004-11-23</lastmod> </url> </urlset> Quote Link to comment Share on other sites More sharing options...
kratsg Posted October 19, 2007 Share Posted October 19, 2007 Is this code used in PHP? Take a look at the eval() function. It allows you to take XML outputted data, and transmit it into an array which is more readily accessible than using RegEx. Quote Link to comment Share on other sites More sharing options...
Axcelcius Posted October 19, 2007 Author Share Posted October 19, 2007 It will be in PHP. The goal is to use PHP to automatically add and delete URLs in the sitemap. Quote Link to comment Share on other sites More sharing options...
effigy Posted October 19, 2007 Share Posted October 19, 2007 I think you can use XPath: url/loc[text() = 'url'] Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.