如何使用 xPath (10g) 在 Oracle SQL extract() 中获取节点名称
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/12964537/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 01:11:17 来源:igfitidea点击:
how to get node name in Oracle SQL extract() with xPath (10g)
提问by Frank
Here is a XML file:
这是一个 XML 文件:
<ROOT>
<A>
<B>2</B>
<C>3</C>
<D>4</D>
</A>
</ROOT>
How to get the tagname "C" through xPath. The function name() does not work here in extract.
如何通过 xPath获取标签名称“C”。函数 name() 在提取中不起作用。
It reports Errors:
它报告错误:
ORA-31011: XML parsing failed ORA-19202: Error occurred in XML processing LPX-00601: Invalid token
gXmlDOM
is the xml string above, how to do this in SQL?
gXmlDOM
是上面的xml字符串,如何在SQL中做到这一点?
select XMLType(gXmlDOM).extract(p_xmlPath).getStringVal() from dual;
回答by mlvnd
This might be what you're looking for...
这可能就是你要找的...
Select xmltype('<ROOT><A><B>2</B><C>3</C><D>4</D></A></ROOT>')
.extract('ROOT/A/*[2]')
.getrootelement()
From dual;