how to create site maps from MySQL database?
An MySQL database contain around 1 million information about domain names. how do I create an xml开发者_如何学Go site map from the said database with PHP 10000 domain names in it.and the xml file should be given a sequent name for example sitemap1.xml,sitemap2.xml
etc.
You can just write XML and save it using file_put_contents()
.
So just loop through all your results and split each file at 10.000 items.
You could use DOMDocument. You can use it like this:
$doc = new DOMDocument();
$doc->formatOutput = true;
$r = $doc->createElement( "employees" );
$doc->appendChild( $r );
foreach( $employees as $employee )
{
$b = $doc->createElement( "employee" );
$name = $doc->createElement( "name" );
$name->appendChild(
$doc->createTextNode( $employee['name'] )
);
$b->appendChild( $name );
}
echo $doc->saveXML();
$doc->save("write.xml")
精彩评论