Oracle
 sql >> Database >  >> RDS >> Oracle

Oracle Pl/SQL:ciclo attraverso i nodi XMLTYPE

Puoi scorrere gli elementi usando EXTRACT e XMLSequence (divide l'XML in blocchi distinti -- qui utenti) in questo modo:

SQL> SELECT extractvalue(column_value, '/user/name') "user"
  2    FROM TABLE(XMLSequence(XMLTYPE(
  3                 '<?xml version="1.0"?>
  4                     <users>
  5                         <user>
  6                             <name>user1</name>
  7                         </user>
  8                         <user>
  9                             <name>user2</name>
 10                         </user>
 11                         <user>
 12                             <name>user3</name>
 13                         </user>
 14                     </users>').extract('/users/user'))) t;

user
--------
user1
user2
user3