我看过null以下几种方式表示的元素:
元素存在于xsi:nil="true":
<book>
<title>Beowulf</title>
<author xsi:nil="true"/>
</book>
Run Code Online (Sandbox Code Playgroud)
该元素存在,但表示为一个空元素(我认为这是错误的,因为'空'并且null在语义上是不同的):
<book>
<title>Beowulf</title>
<author/>
</book>
<!-- or: -->
<book>
<title>Beowulf</title>
<author></author>
</book>
Run Code Online (Sandbox Code Playgroud)
返回的标记中根本不存在该元素:
<book>
<title>Beowulf</title>
</book>
Run Code Online (Sandbox Code Playgroud)
该元素有一个<null/>子元素(来自下面的TStamper):
<book>
<title>Beowulf</title>
<author><null/></author>
</book>
Run Code Online (Sandbox Code Playgroud)
是否有正确或规范的方式来表示这样的null价值?还有其他方法吗?
以上示例的XML是人为设计的,所以不要过多地阅读它.:)