生成XML - 排除节点

时间:2016-07-22 15:13:58

标签: sql xml oracle

请参阅下面的SQL:

select dbms_xmlgen.getxml('select incident_id FROM INCIDENTS where incident_id=600') xml
from dual

它返回:

<?xml version="1.0"?>
<ROWSET>
 <ROW>
  <INCIDENT_ID>600</INCIDENT_ID>
 </ROW>
</ROWSET>

如何排除退回:

<SYSTEM URN="114644">
<INCIDENT_ID>600</INCIDENT_ID>
<SYSTEM>

我想硬编码XML的第一行和第三行。

1 个答案:

答案 0 :(得分:1)

使用提取功能获得所需的输出

EXTRACT (XML) is similar to the EXISTSNODE function. 
It applies a VARCHAR2 XPath string and returns an XMLType instance containing an XML fragment. You can specify an absolute XPath_string with an initial slash or a relative XPath_string by omitting the initial slash. 
If you omit the initial slash, the context of the relative path defaults to the root node...

这里也看到类似的问题 https://community.oracle.com/thread/1126429?tstart=0