需要计算包含
的文件数量//SIGNOFF/ACCOMPBY@AUTH="M"
//SIGNOFF/INSPBY@AUTH="I"
输入XML:
<SIGNOFF ID="S0001">
<ACCOMPBY ID="JCAT0001" AUTH="M"/>
<INSPBY ID="JCIT0001" AUTH="I"/>
</SIGNOFF>
一直在玩这样的事......
//SIGNOFF/ACCOMPBY[contains (@AUTH, 'M')]/INSPBY[contains (@AUTH, 'I')]/ancestor::TASKCARD/@CARDNBR/concat("",.)
非常感谢正确方向的任何一点!
答案 0 :(得分:0)
你的问题不是很清楚,但我会试一试。假设一个更明智的输入文档(在包含正面和负面示例的意义上更明智):
<root>
<SIGNOFF ID="YES">
<ACCOMPBY ID="JCAT0001" AUTH="M"/>
<INSPBY ID="JCIT0001" AUTH="I"/>
</SIGNOFF>
<SIGNOFF ID="NO">
<ACCOMPBY ID="JCAT0001" AUTH="OTHER"/>
<INSPBY ID="JCIT0001" AUTH="I"/>
</SIGNOFF>
<SIGNOFF ID="NO">
<ACCOMPBY ID="JCAT0001" AUTH="M"/>
<INSPBY ID="JCIT0001" AUTH="OTHER"/>
</SIGNOFF>
</root>
您可以使用以下XPath表达式:
//SIGNOFF[ACCOMPBY/@AUTH = 'M' and INSPBY/@AUTH = 'I']
只产生一个结果,SIGNOFF
元素:
<SIGNOFF ID="YES">
<ACCOMPBY ID="JCAT0001" AUTH="M"/>
<INSPBY ID="JCIT0001" AUTH="I"/>
</SIGNOFF>