xpath - How to retrieve attribute values of each element in xml as rows in xmlytpe oracle -
i having following xml
<books> <book max="30" min="10"> .. </book> <book max="20" min="5"> .. </book> <book max="50" min="10"> .. </book> <book max="40" min="25"> .. </book> </books
i want output particular xml file as,
max_attrib min_attrib30 10
20 5
50 10
40 25
my current query,
select max_attrib , min_attrib sampletable , xmltable( '/books/book' passing sampletable.xmlcolumn columns max_attrib varchar2(20) path '@max') , xmltable( '/books/book' passing sampletable.xmlcolumn columns min_attrib varchar2(20) path '@min') ;
gives output max , min attribute of book in xml. how values.
with sampletable ( select xmltype(' <books> <book max="30" min="10"> .. </book> <book max="20" min="5"> .. </book> <book max="50" min="10"> .. </book> <book max="40" min="25"> .. </book> </books> ') xmlcolumn dual ) select x.* sampletable, xmltable('/books/book' passing sampletable.xmlcolumn columns max_attrib varchar2(20) path '@max', min_attrib varchar2(20) path '@min' ) x ;
Comments
Post a Comment