PHP 和 sitemap.xml [英] PHP and sitemap.xml

查看:31
本文介绍了PHP 和 sitemap.xml的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我计划构建一个脚本,该脚本将为我的站点创建一个 sitemap.xml,例如,每天(cron 将执行该脚本).我应该只构建 XML 字符串并将其保存为文件吗?或者使用 PHP 的类/函数/等之一会有什么好处.用于 XML?

I am planning to build a script that will create a sitemap.xml for my site, say, every day (cron will execute the script). Should I just build the XML string and save it as a file? Or would there be some benefit to using one of PHP's classes/functions/etc. for XML?

如果我应该使用某种 PHP 类/函数/等,它应该是什么?

If I should be using some sort of PHP class/function/etc., what should it be?

推荐答案

对于简单的 XML,只输出字符串通常更容易.但是,文档越复杂,使用 XML 库(PHP 或第三方脚本中包含的库)的好处就越大,因为它可以帮助您输出正确的 XML.

For simple XML it is often easier to just output the string. But the more complex your document gets, the more benefit you will get from using an XML library (either those included with PHP or a third party script) as it will help you to output correct XML.

对于站点地图,您可能最好只写字符串.

For a sitemap, you would probably be best just writing the string.

这篇关于PHP 和 sitemap.xml的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆