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> Link to comment https://forums.phpfreaks.com/topic/73886-finding-code/ 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. Link to comment https://forums.phpfreaks.com/topic/73886-finding-code/#findComment-372927 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. Link to comment https://forums.phpfreaks.com/topic/73886-finding-code/#findComment-372936 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'] Link to comment https://forums.phpfreaks.com/topic/73886-finding-code/#findComment-373177 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.