Do sitemap.xml today. Find a foreign site, http://www.freesitemapgenerator.com/This can generate 5,000 data, previously found that can only generate 500. However, some of the generated XML tags are useless, 650) this.width=650; "Src=" http://s3.51cto.com/wyfs02/M01/5A/12/ Wkiol1t1rsfzleagaayym92b1fs402.jpg "title=" Loc.png "alt=" Wkiol1t1rsfzleagaayym92b1fs402.jpg "/>
So I think of the PHP processing file, a line of reading, and the useless row deleted.
The code is as follows:
<?php set_time_limit (0), $file =fopen (' Sitemap.xml ', ' R '), while (!feof ($file)) {$line = Fgets ($file); $arr []= $line; $reg = "/<priority>|<lastmod>|<changefreq>/"; if (!preg_match ($reg, $line)) {$arr []= $line;} if ()//echo $line;} Fclose ($file);//var_dump ($arr), $str = Implode ("\ r \ n", $arr); File_put_contents ("1.xml", $str);
But login a company's again let Change, say is Loc in Can't still have? No. I thought of writing a loop directly, but the time for bitterness began. See http://ningyuqiao.blog.51cto.com/5581274/1616984
Paste the Code bar:
<?php set_time_limit (0); $xml _str = file_get_ Contents ("1.xml"); $doc = domdocument::loadxml ($xml _str); $root = $ doc->documentelement; $items = $root->getelementsbytagname (' url ');// echo $length;// die (); for ($i = 0; $i < $items->length; $i + +) { // echo $items->item ($i)->nodevalue . "\ n"; $url = $items->item ($i)->nodevalue; $reg = "/\?/"; if (Preg_ Match ($reg, $url)) { echo $url; $root->removechild ($items- >item ($i)); } // sleep (3);} $doc->formatoutput = true; $doc->savexml (), $doc->save ("1.xml");
Finally done, the psychology is very happy, share to everyone.
This article is from my blog blog, so be sure to keep this source http://ningyuqiao.blog.51cto.com/5581274/1616986
PHP handles files, reads one line at a line, and deletes useless rows.