gpt4 book ai didi

xml - 前缀 '' 不能在同一起始元素标记内从 '' 重新定义为 'http://www.sitemaps.org/schemas/sitemap/0.9'

转载 作者:数据小太阳 更新时间:2023-10-29 01:39:59 25 4
gpt4 key购买 nike

我遇到了这个错误

The prefix '' cannot be redefined from '' to 'http://www.sitemaps.org/schemas/sitemap/0.9' within the same start element tag

运行这段代码时

Dim writer As XmlWriter = XmlWriter.Create(FileLocation + "StaticUrls3.xml")
Dim urlList As New List(Of String)

urlList.Add("link1")
urlList.Add("link2")
urlList.Add("link3")

writer.WriteStartDocument()
writer.WriteStartElement("urlset")
writer.WriteAttributeString("xmlns", "http://www.sitemaps.org/schemas/sitemap/0.9")

For Each aUrl As String In urlList
writer.WriteStartElement("url")
writer.WriteElementString("loc", aUrl)
writer.WriteEndElement()
Next

writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()

为什么会出现此错误?

最佳答案

试试这个:

Const siteMapNamespace As String = "http://www.sitemaps.org/schemas/sitemap/0.9"
Dim writer As XmlWriter = XmlWriter.Create(FileLocation + "StaticUrls3.xml")
Dim urlList As New List(Of String)

urlList.Add("link1")
urlList.Add("link2")
urlList.Add("link3")

writer.WriteStartDocument()
writer.WriteStartElement("urlset", siteMapNamespace)

For Each aUrl As String In urlList
writer.WriteStartElement("url", siteMapNamespace)
writer.WriteElementString("loc", aUrl)
writer.WriteEndElement()
Next

writer.WriteEndElement()
writer.WriteEndDocument()
writer.Close()

关于xml - 前缀 '' 不能在同一起始元素标记内从 '' 重新定义为 'http://www.sitemaps.org/schemas/sitemap/0.9',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3805790/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com