【发布时间】:2015-07-13 12:19:28
【问题描述】:
我有一个 XmlWriter,它已经有一个带有 xmlns 属性集的根元素。
我现在有一个 XElement(有很多子元素),没有指定命名空间。
如果我这样做:
xElement.WriteTo(writer);
我以无效的 xml 结尾:
<MyRootElement xmlns="SomeNameSpace">
<!-- Some elements of this namespace -->
<MyXElementType xmlns="">
<!-- A lot of other Element in the same namespace -->
</MyXelementType>
<!-- Some elements of this namespace -->
</MyRootElement>
因为禁止指定空的命名空间。这是有问题的,因为我需要在 XSD 之后进行验证。
我能做些什么来结束这个:
<MyXElementType><!-- HERE, no xmlns !!! -->
<!-- A lot of other Element in the same namespace -->
</MyXelementType>
<!-- Some elements of this namespace -->
</MyRootElement>
【问题讨论】:
标签: c# .net xml xelement xmlwriter