将XML数据(我从网页上获得)插入PostgreSQL数据库的最佳方法是什么?
我正在使用Java,需要一些帮助,找到一种将数据读入数据库的好方法.
我一直在尝试以与@Erwin Brandstetter用可接受的答案回答几次相同的方式从 XML 中提取值,但它对我不起作用:
根据这篇文章和这篇文章,这应该可以工作,但我只是得到一个空结果:
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
Run Code Online (Sandbox Code Playgroud)
结果:(预期:{我的评论})
comment
xml[]
-------
{}
Run Code Online (Sandbox Code Playgroud)
我的数据库版本:
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
Run Code Online (Sandbox Code Playgroud)
有人有想法吗?