Я использую классический ASP для создания файлов sitemap.xml, однако у меня возникает небольшая проблема, которую я не могу понять. Моя цель - повиноваться этому:
http://www.sitemaps.org/protocol.html
Проблема в моем выводе. Я не могу понять, как остановить печать xmlns="" внутри тега URL. он должен отображаться только в теге urlset
Вот рабочий ASP/VBScript для вырезания и вставки:
Dim theDom, theRoot, theParent,theChild, theID, docInstruction
Set theDom = Server.CreateObject("Microsoft.XMLDOM")
Set theRoot = theDom.createElement("urlset")
Set theID = theDom.createAttribute("xmlns")
theID.Text = "http://www.sitemaps.org/schemas/sitemap/0.9"
theRoot.setAttributeNode theID
theDom.appendChild theRoot
Set theParent = theDom.createElement("url")
Set theChild = theDom.createElement("loc")
theChild.Text = "http://someURL.com"
theRoot.appendChild theParent
theParent.appendChild theChild
Set theChild = theDom.createElement("changefreq")
theChild.Text = "weekly"
theRoot.appendChild theParent
theParent.appendChild theChild
Set theParent = theDom.createElement("url")
Set theChild = theDom.createElement("loc")
theChild.Text = "http://someOtherUrl.com"
theRoot.appendChild theParent
theParent.appendChild theChild
Set theChild = theDom.createElement("changefreq")
theChild.Text = "weekly"
theRoot.appendChild theParent
theParent.appendChild theChild
Set docInstruction = theDom.createProcessingInstruction("xml","version='1.0' encoding='UTF-8'")
theDom.insertBefore docInstruction, theDom.childNodes(0)
theDom.Save Server.MapPath("MyXMLDoc.xml")
и вот вывод созданного XML-файла. Как я могу запретить отображение xmlns="" в теге url, но убедиться, что он остается в теге urlset??
<?xml version="1.0" encoding="UTF-8" ?>
- <urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">
- <url xmlns="">
<loc>http://someURL.com</loc>
<changefreq>weekly</changefreq>
</url>
- <url xmlns="">
<loc>http://someOtherUrl.com</loc>
<changefreq>weekly</changefreq>
</url>
</urlset>