XmlTextWriter手动声明命名空间C#

时间:2018-07-25 22:26:31

标签: c# sitemap xmlwriter

此代码来自msdn c#

service cloud.firestore {
  match /databases/{database}/documents {
    match /cats/{catId} {
        allow read;
      allow update, create, write, delete: if resource.data.ownerId == request.auth.uid;
    }
  }
}

输出:

writer.WriteStartElement("root");
writer.WriteAttributeString("xmlns", "x", null, "urn:1");
writer.WriteStartElement("item", "urn:1");
writer.WriteEndElement();
writer.WriteStartElement("item", "urn:1");
writer.WriteEndElement();
writer.WriteEndElement();

在这里我得到的错误是错误,它不是在创建我的xml

    <root xmlns:x="urn:1">
    <x:item/>
    <x:item/>
    </root>

但是当我尝试这样做时,我可以生成<< strong> xhtml:link 元素对Google来说这无效

    writer.WriteAttributeString("xmlns", "xhtml", null, "http://www.w3.org/1999/xhtml");
    writer.WriteStartElement("link", "http://www.w3.org/1999/xhtml");

区别只是URL的上的 SLASH (/)

0 个答案:

没有答案