删除重复的命名空间

时间:2014-06-12 20:07:32

标签: c# xml linq-to-xml xml-namespaces

所以,我想写出来:

<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
...
    <w:rPr xmlns="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
        <w:shadow />
        <p2:u p2:val="dottedHeavy" p2:color="00CCFF" xmlns:p2="http://schemas.openxmlformats.org/wordprocessingml/2006/main" />
        <p2:effect p2:val="lights" xmlns:p2="http://schemas.openxmlformats.org/wordprocessingml/2006/main" />
        <p3:caps p3:val="true" xmlns:p3="http://schemas.openxmlformats.org/wordprocessingml/2006/main" />
    </w:rPr>
...
</w:document>

这是

<w:document xmlns:w="http://schemas.openxmlformats.org/wordprocessingml/2006/main">
...
    <w:rPr>
        <w:caps/>
        <w:shadow/>
        <w:u w:color="00CCFF" w:val="dottedHeavy"/>
        <w:effect w:val="lights"/>
    </w:rPr>
...
</w:document>

使用xdoc.Save(file, SaveOptions.OmitDuplicateNamespaces),但生成的文件仍然具有重复的命名空间。由于这不起作用,如何从XDocument中删除重复的名称空间?我尝试使用XmlReaderXmlWriterXmlDocument及其等效选项,但仍然无效。

P.S。在您想知道的情况下,即表示排除数据的...的docx数据

0 个答案:

没有答案