我目前无法从Xdocument的根节点删除麻烦的属性: xml:base 。
我的Xdocument currentDoc :
<root xml:base="texthere">
<child/>
</root>
我查看了有关xml:base的文档:http://www.w3.org/TR/xmlbase/。
我在使用C#代码时遇到了麻烦,因为这个 xml:前缀没有像其他名称空间前缀那样的声明。
这就是我的工作:
currentDoc.Root.Attributes().Where(a => a.IsNamespaceDeclaration).Remove();
答案 0 :(得分:1)
&#34; xml&#34;定义名称空间:
currentDoc.Root.Attributes(XNamespace.Xml + "base").Remove();