[英]Xpath condition get parent
這是我的xml:
<people>
<person id="0001">
<firstname>Christopher</firstname>
<lastname>Shaw</lastname>
<birthdate>1975-02-23T21:24:46.000+02:00</birthdate>
<healthprofile>
<lastupdate>2014-09-30T10:38:07.000+02:00</lastupdate>
<weight>84</weight>
<height>2.13</height>
<bmi>18.51</bmi>
</healthprofile>
</person>
<person id="0002">
<firstname>Brian</firstname>
<lastname>Tooley</lastname>
<birthdate>1987-10-19T08:18:59.000+02:00</birthdate>
<healthprofile>
<lastupdate>2014-09-30T10:38:07.000+02:00</lastupdate>
<weight>98</weight>
<height>2.17</height>
<bmi>20.81</bmi>
</healthprofile>
</person>
</people>
我想使用Xpath進行的工作是提取那些權重等於80的用戶的名字。 我無法使它正常工作。
您可以嘗試這樣的事情:
/people/person[healthprofile/weight='80']/firstname
基本上在XPath上方查找具有<weight>
后代等於80
<person>
元素,然后從該<person>
獲得<firstname>
元素。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.