2
我已經徹底搜索,沒有找到任何示例或指導我如何查詢和檢索多個XML兄弟姐妹的值。如何檢索多個XML兄弟 - SQL Server
有很多關於如何檢索單個兄弟值的示例。
例如,給定下面的XML片段:
<StoreSurvey>
<AnnualSales>800000</AnnualSales>
<AnnualRevenue>80000</AnnualRevenue>
<BankName>United Security</BankName>
<BusinessType>BM</BusinessType>
<YearOpened>1996</YearOpened>
<Specialty>Mountain</Specialty>
<SquareFeet>21000</SquareFeet>
<Brands>2</Brands>
<Internet>ISDN</Internet>
<NumberEmployees>13</NumberEmployees>
<Products Type="Bikes">
<Product>Mountain</Product>
<Product>Road</Product>
<Product>Racing</Product>
</Products>
<Products Type="Clothes">
<Product>Jerseys</Product>
<Product>Jackets</Product>
<Product>Shorts</Product>
</Products>
</StoreSurvey>
如果我想要檢索的<AnnualSales>
的價值,我可以執行在查詢分析器以下語句:
SELECT Survey_untyped.query('/StoreSurvey/AnnualSales')
FROM Stores;
結果集將正確顯示
<AnnualSales>800000</AnnualSales>
但是,如果我想重新發現<AnnualSales>
AND <AnnualRevenue>
?我會怎麼做?
查詢應提供的結果集看起來像:
<AnnualSales>800000</AnnualSales>
<AnnualRevenue>80000</AnnualRevenue>
或者,如果我要三兄弟的,除了那些值的值「BANKNAME」?結果集是這樣的:
<AnnualSales>800000</AnnualSales>
<AnnualRevenue>80000</AnnualRevenue>
<BankName>United Security</BankName>
有誰知道這個問題的答案?
謝謝,我還沒有看到任何使用該語法的引用,使用「自我」等語法。你可以請發佈一個鏈接? (我一直在尋找標準的x-query示例等) – SharmaVenkati
實際上,現在我看起來我在那裏看到「自我」,但它被描述爲選擇「當前節點」從來沒有看到任何像你的例子,但謝謝你非常,你爲我節省了很多時間。再次感謝。 – SharmaVenkati
@SharmaVenkati:根據您的要求更新self :: axis鏈接。 – kjhughes