[英]how to create site maps from MySQL database?
An MySQL database contain around 1 million information about domain names. 一个MySQL数据库包含大约一百万个有关域名的信息。 how do I create an xml 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. 我该如何从上述数据库中创建一个具有PHP 10000域名的xml站点地图,并且应该给xml文件一个后续名称,例如
sitemap1.xml,sitemap2.xml
等。
You can just write XML and save it using file_put_contents()
. 您可以编写XML并使用
file_put_contents()
保存它。 So just loop through all your results and split each file at 10.000 items. 因此,只需遍历所有结果并将每个文件拆分为10.000项即可。
You could use DOMDocument. 您可以使用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")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.