[英]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.