如何使用XMLBeans删除xsi:nil =" true

时间:2011-07-26 21:34:41

标签: xml xsd marshalling xmlbeans xml-nil

使用XMLBeans生成XML时,

xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"得到  插入

例如:

<element xsi:nil="true" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"/>

但我只需要<element/>

请建议。 提前谢谢。

1 个答案:

答案 0 :(得分:1)

我只能建议在setter中放入一个空的(默认值),将其保留为null将导致nil,另一种方法是你可以删除nil属性:

xnode.RemoveAttribute("nil", "http://www.w3.org/2001/XMLSchema-instance");

其中xnode是具有nil值的节点。

希望有所帮助