I have the following XML file.
I am writing an XPath query to return the concatenation of fname
and weight
for all orders with weight>50
.
<purple>
<customer cid="1">
<fname>John</fname>
<lname>Klingard</lname>
<apt>27</apt>
<street>30th Winstonhut St.</street>
<pobox>199183</pobox>
</customer>
<customer cid="2">
<fname>Anthony</fname>
<lname>Hurro</lname>
<apt>86</apt>
<street>Town St.</street>
<pobox>177162</pobox>
</customer>
<order oid="1">
<eta>2016-04-23</eta>
<weight>55</weight>
<custid>1</custid>
</order>
<order oid="2">
<eta>2016-05-03</eta>
<weight>75</weight>
<custid>2</custid>
</order>
</purple>
I have written the query as:
concat(
/purple/customer[@cid=/purple/order[weight>50]/custid]/fname/text(),
/purple/order[weight>50]/weight/text())
The output is:
John55
The desired output is:
John55
Anthony75
Any advice on how I can achieve this?