不需要的 xmlns="" 在 _di_IXMLNode 中
我正在使用 _di_IXMLDocument 创建一个用于在 Excel 中显示的 xml 文件。 但对于某些标签,我得到了一个不需要的额外(空)xmlns 属性,这使得 Excel 无法读取该文件... 这就是我所做的:
...
_di_IXMLNode worksheet = workbook->AddChild("Worksheet");
worksheet->SetAttribute("ss:Name",Now().DateString());
...
这就是结果:
<Worksheet xmlns="" ss:Name="2008-12-11">
xmlns 来自哪里? 我该如何摆脱它?
编辑: 更多信息:如果我尝试自己向工作表添加 xmlns 属性,如下所示:
...
_di_IXMLNode worksheet = workbook->AddChild("Worksheet");
worksheet->SetAttribute("xlmns","Foo");
worksheet->SetAttribute("ss:Name",Now().DateString());
...
那么“工作表”的子节点都会获得空的 xmlns 属性!
<Worksheet xmlns="Foo" ss:Name="2008-12-11">
<Table xmlns="">
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
xmlns 代表 xml 名称空间,如果属性没有接收显式名称空间,则它不拥有任何名称空间。
http://www.w3.org/TR/REC-xml-names/< /a>
xmlns stands for xml name space, if an attribute does not receive an explicit name space, it possesses none.
http://www.w3.org/TR/REC-xml-names/
好的,我查看了这个 问题。 诀窍是创建子节点并告诉它们属于哪个名称空间,然后不输出它......
这会产生所需的输出:
Ok I had a look at this question. The trick was to create the child nodes and telling the what namespace they belong to, and then not to output it...
this produces the desired output: