Tell me what the problem may be: it is required to delete nodes on the google sitemap by the condition, but for some reason during the search it is impossible to delete them correctly. Separate from brute force removed. Tried through simplexml and Dom in different ways. Code: http://dumpz.org/592858/ Source: http://dumpz.org/592860/

At the output: dom.xml: http://dumpz.org/592867/ dom_work.xml: http://dumpz.org/592868/ simplexml.php: http://dumpz.org/592874/ simplexml_inner.xml: http : //dumpz.org/592876/

    1 answer 1

    $xml = simplexml_load_file('sitemap.xml'); $url_total = count($xml->url); for ($i = ($url_total - 1); $i >= 0; --$i) { if (!strpos($xml->url[$i]->loc, 'forum')) { continue; } else { unset($xml->url[$i]); } } $xml->asXML("simplexml.xml"); 

    As you can see, neither additional variables like arrays, nor regular expressions are needed.