ASP创建XML文件,新建子节点总是自动加上了根节点的属性!高手来帮忙!在线等!

mfkiqpl mfkiqpl 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
这是一个制作SiteMaps的一段asp源码。
set xml=server.CreateObject("MSXML.DOMDocument")
set st=xml.createProcessingInstruction("xml","version=""1.0"" encoding=""UTF-8""")
xml.appendchild(st)
set r_=xml.createelement("urlset")'根节点
set it=xml.createelement("url") '子节点
set lc=xml.createelement("loc")
lc.text="http://www.zjjnet.com"
set md=xml.createelement("lastmod")
md.text="2003-2-2"
set ch=xml.createelement("changefreq")
ch.text="daily"
set pr=xml.createelement("priority")
pr.text="0.8"
it.appendchild(lc)
it.appendchild(md)
it.appendchild(ch)
it.appendchild(pr)
r_.appendchild(it)

set att=xml.createattribute("xmlns")
att.text="http://www.google.com/schemas/sitemap/0.84"
r_.attributes.setNamedItem(att)'给根节点加上xmlns属性
'r_.attributes.removeNamedItem("xmlns")
xml.appendchild(r_)
xml.save(server.MapPath(".")&"/xml.xml")'保存XML文件
set r_=nothing
set xml=nothing

通过以上的代码创建的XML文件。如下:
<?xml version="1.0" encoding="UTF-8" ?>
- <urlset xmlns="http://www.google.com/schemas/sitemap/0.84">
- <url xmlns="">
<loc>http://www.zjjnet.com</loc>
<lastmod>2003-2-2</lastmod>
<changefreq>daily</changefreq>
<priority>0.8</priority>
</url>
</urlset>
urlset 节点的属性 xmlns 有值,这是我需要的

但 url节点也多了个属性,xmlns 没有值 这是我不需要的,也没有给url节点添加属性。它为什么会加上xmlns属性呢?
如果让新建的url节点不自动加上xmlns属性??
...全文
评论 5
收藏 已收藏
分享
返回顶部
mfkiqpl
ASP 28,401 成员 356,940 内容