使用xpath从Postgres XML获取属性名称

时间:2018-01-23 06:41:49

标签: xml postgresql xpath

我正处于可以获取xml节点的位置:

select xml_ from (...) a;
-------------
<something att1="abc" att2="123" att3="foo"/>
...
<something att1="def" att2="456" att3="bar"/>
-------------

select xpath('./@*', xml_) from (...) a;
-------------
{"abc", "123", "foo"}
...
{"def", "456", "bar"}
-------------

我想得到的是

select magic(xml_) from (...) a;
-------------
{"att1", "att2", "att3"}
...
{"att1", "att2", "att3"}
-------------

请帮忙。谢谢!!!

第二个代码段在这里运行 - &gt; http://sqlfiddle.com/#!17/9eecb/8570/0

0 个答案:

没有答案