开发者

How is empty node tag in xml and non-existence of node interpreted?

开发者 https://www.devze.com 2023-04-04 15:32 出处:网络
I have two XML request: <GetPersonRequest> <Person/> <IncludeAddress>true</IncludeAddress>

I have two XML request:

<GetPersonRequest>
    <Person/>
    <IncludeAddress>true</IncludeAddress>
</GetPersonRequest>

and

<GetPersonRequest>
    <IncludeAddress>true</IncludeAddress>
</GetPersonRequest>

Is there a difference between empty nodes and non-existence of nodes ? Does the XML parser makes any difference ?. Does call to text of both node returns empty string ?

I w开发者_如何学运维ould like to add that second XML is similar in that element is optional. So the user might just omit. Does xml.getElement("Person") still return null ?


These XMLs are different. 1st XML contains element Person (empty element, its text() is null), while 2nd doesn't. For 2nd XML (pseudo-code) xml.getElement("Person") will return null.

0

精彩评论

暂无评论...
验证码 换一张
取 消