[英]Returning attribute value using Xquery
我需要返回cno和zip
x在客戶/客戶中
z在客戶/客戶/城市
返回{data($ x / @ cno)}
{$ z /郵政編碼}
它返回每個cno,我需要與cno相匹配的郵政編碼
<customers>
<customer cno="2222">
<city>
<zip>67226</zip>
<phone>316-636-5555</phone>
</city>
</customer>
<customer cno="1000">
<city>
<zip>67226-1555</zip>
<phone>000-000-0000</phone>
</city>
</customer>
</customers>
以下查詢返回您描述的結果:
xquery version "3.1";
for $customer in /customers/customer
return
$customer/@cno || ": " || $customer/city/zip
結果:
2222: 67226
1000: 67226-1555
完整的示例代碼可以在http://xqueryfiddle.liberty-development.net/jyyiVhv中找到。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.