[英]How To retrieve value of an element from same name multiple elements in XML through xQuery?
我在sql server中有和xml這樣的字段
<propertyDetail>
<importID>1735532</importID>
<pincode />
<landmarks />
<features>
<feature>Society Name: sec-87 srs peral floor faridabad</feature>
<feature>Transaction: Resale Property</feature>
<feature>Possession: Dec,2011</feature>
<feature>*Ownership: Freehold*</feature>
<feature>Age of Property: Under Construction</feature>
</features>
</propertyDetail>
我想通過xQuery檢索具有“ Ownership:Freehold ”值的功能,並且功能序列可能會有所不同。
歡迎任何建議。
您可以在過濾器表達式中檢查該功能是否存在,即:
//propertyDetail[features/feature[. eq "*Ownership: Freehold*"]]
其中@x
是你的xml
select @x.query('//feature[. = "*Ownership: Freehold*"]')
如果你想找到以所有權開頭的任何東西
select @x.query('//feature[substring(.,1,9)="Ownership"]')
(但理想情況下,如果可以,您應該改進XML結構)
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.