下面是我的元素层次结构。如何检查(使用 XPath)AttachedXml 元素是否存在于 Primary Consumer
的 CreditReport 下<Consumers xmlns="http://xml.mycompany.com/XMLSchema">
<Consumer subjectIdentifier="Primary">
<DataSources>
<Credit>
<CreditReport>
<AttachedXml><![CDATA[ blah blah]]>
最佳答案
The boolean function converts its argument to a boolean as follows:
a number is true if and only if it is neither positive or negative zero nor NaN
a node-set is true if and only if it is non-empty
a string is true if and only if its length is non-zero
an object of a type other than the four basic types is converted to a boolean in a way that is dependent on that type
如果primaryConsumer的CreditReport中有AttachedXml,则返回真()
。
boolean(/mc:Consumers
/mc:Consumer[@subjectIdentifier='Primary']
//mc:CreditReport/mc:AttachedXml)
关于java - 如何使用 XPath 检查 XML 中是否存在元素?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5689966/