我一直試圖從XML中提取值,方法與@Erwin Brandstetter用已接受的答案回答了幾次,但它不適用於我:Postgresql:使用xpath從XML列中提取數據
根據this post和this post這應該工作,但我只是得到一個空結果:
WITH x AS (SELECT
'<Attributes xmlns="http://www.gis34.dk">
<bemaerkning displayName="Bemærkning">Beatrix</bemaerkning>
<billede displayName="Billede">https://vignette.wikia.nocookie.net/killbill/images/3/39/The_Bride.jpg</billede>
</Attributes>'::xml AS t
)
SELECT xpath('/Attributes/bemaerkning/text()', t) as comment
FROM x
結果: (預期:{我的評論})
comment
xml[]
-------
{}
我的數據庫版本:
PostgreSQL 9.1.3 on x86_64-unknown-linux-gnu, compiled by gcc-4.5.real (Ubuntu/Linaro 4.5.2-8ubuntu4) 4.5.2, 64-bit
任何人有一個想法?
檢查這一項:
注意周圍的函數調用括號:http://stackoverflow.com/questions/17799790/using-xpath-to-extract-data-from-an-xml-column-in-postgres – har07
@ har07,這個鏈接是我的問題中的兩個參考之一。 .. :-) – Ambran