0

我在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检索具有“所有权:永久业权”价值的特征,并且特征序列可能会有所不同。

欢迎任何建议。

4

2 回答 2

1

您可以在过滤器表达式中检查该功能是否存在,即:

//propertyDetail[features/feature[. eq "*Ownership: Freehold*"]]
于 2012-10-30T10:08:49.433 回答
1

@x你的xml在哪里

select @x.query('//feature[. = "*Ownership: Freehold*"]')

如果你想找到任何以所有权开头的东西,那么

select @x.query('//feature[substring(.,1,9)="Ownership"]')

(但理想情况下,如果可以的话,您应该改进您的 XML 结构)

于 2012-10-30T10:26:15.173 回答