本文介紹了在 SQL Server XPath 中獲取跟隨兄弟的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
限時送ChatGPT賬號..
由于 SQL Server 不支持跟隨兄弟軸 - 獲得它的最佳方法是什么?假設我有這樣的 XML,我想在匹配值 'dog' 的節點之后獲取第一個 'b' 節點:
Since SQL Server does not support following-sibling axis - what is the best way to get it? Let's say I have XML like this and I would like to get the first 'b' node after a node matching the value 'dog':
<root>
<a>cat</a>
<b>Cats don't like milk</b>
<a>dog</a>
<b>Dogs like everything</b>
</root>
推薦答案
你可以嘗試這樣的事情.
You could try something like this.
declare @X xml = '
<root>
<a>cat</a>
<b>Cats don''t like milk</b>
<a>dog</a>
<c>not this</c>
<b>Dogs like everything</b>
<b>and not this</b>
</root>'
select @X.query('(/root/b[. >> (/root/a[. = "dog"])[1]])[1]')
這篇關于在 SQL Server XPath 中獲取跟隨兄弟的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!