我需要选择一个节点的属性"given or family",该节点的属性名为TypeCode,值为REF,我找不到正确的XPath查询
<participant typeCode="IND">
<associatedEntity classCode="giver">
<associatedPerson>
<name>
<given>Administrator</given>
<family>test</family>
</name>
</associatedPerson>
</associatedEntity>
</participant>
<participant typeCode="REF">
<time value="20151013000000+0200"/>
<associatedEntity classCode="PROV">
<associatedPerson>
<name>
<given>TestBIB1</given>
<family>Train1B</family>
</name>
</associatedPerson>
</associatedEntity>
</participant>'
要选择属性为typeCode="REF"
的节点,请使用XPath:
//*[@typeCode="REF"]
要特别选择具有typeCode="REF"
属性的participant
元素,请使用XPath:
//participant[@typeCode="REF"]
选择给定的/family元素,使用:
//participant[@typeCode="REF"]/associatedEntity/associatedPerson/name/given
或
//participant[@typeCode="REF"]/associatedEntity/associatedPerson/name/family
可能的XPath是
//participant[@typeCode="REF"]/associatedEntity/associatedPerson/name
同时选择given
和family
元素。
你需要澄清"给定或家庭"是什么意思,如果你需要选择文本内容,等等。这可能会导致对上面的表达式进行一些调整。