如何仅提取此 xml 元素中的子标签

How to extract only the subtag in this xml element

通过这个查询我可以select标签的内容

select xmltype(
  '<?xml version="1.0"?> 
  <ROWSET> 
    <ROW>
      <PERSON_NUMBER>1000142</PERSON_NUMBER>
      <LOAN_1>25000</LOAN_1>
    </ROW> 
    <ROW>
      <PERSON_NUMBER>1000142</PERSON_NUMBER>
      <LOAN_1>25000</LOAN_1>
    </ROW> 
  </ROWSET>'
).extract( '/ROWSET/ROW' ) .getstringval() p#
from dual;

<PERSON_NUMBER>1000142</PERSON_NUMBER><LOAN_1>25000</LOAN_1><PERSON_NUMBER>1000142</PERSON_NUMBER><LOAN_1>25000</LOAN_1>

但我想要的是子标签列表。

此示例的预期结果为:

PERSON_NUMBER, LOAN_1

code

类似,可以得到name() XPATH值:

SELECT DISTINCT name
from XMLTABLE(
       '/ROWSET/ROW/*'
       PASSING xmltype(
         '<?xml version="1.0"?> 
         <ROWSET> 
           <ROW>
             <PERSON_NUMBER>1000142</PERSON_NUMBER>
             <LOAN_1>25000</LOAN_1>
             <LOAN_2>26000</LOAN_2>
           </ROW> 
           <ROW>
             <PERSON_NUMBER>1000142</PERSON_NUMBER>
             <LOAN_1>25000</LOAN_1>
             <LOAN_2>26000</LOAN_2>
           </ROW> 
         </ROWSET>'
       )
       COLUMNS
         name VARCHAR2(200) PATH './name()'
     );

输出:

NAME
PERSON_NUMBER
LOAN_1
LOAN_2

db<>fiddle here