xml – 帮助:前缀“’不能从同一起始元素标签中的”到’http://www.sitemaps.org/schemas/sitemap/0.9’重新定义

前端之家收集整理的这篇文章主要介绍了xml – 帮助:前缀“’不能从同一起始元素标签中的”到’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")
    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()
原文链接:https://www.f2er.com/xml/292941.html

猜你在找的XML相关文章