我遇到了一些問題xpath()。考慮下面的示例 XML:
<data code = '123' platform = 'a' xmlns = "http://www.myexample.com" >
<payload>
<title> this is it! </title>
</payload>
</data>
這是存盤在xml資料庫中我的列中的內容。我只是想檢索this is it!文本。我嘗試了許多不同的查詢(我認為問題可能是名稱空間),沒有任何效果。
例如:
select *, xpath('//my:payload/text()',
xml::xml,
ARRAY[ARRAY['my','http://www.myexample.com']]) from mydatabase
什么都不回傳。有任何想法嗎?謝謝!
uj5u.com熱心網友回復:
從我使用的 XML 回傳資料xmltable
select *
from T
cross join xmltable(xmlnamespaces ('http://www.myexample.com' as m),
'/m:data/m:payload'
passing cast(xml_column as xml)
columns title text path 'm:title'
) as x
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/525003.html
