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_attrib
30 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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

thorough guide for profiling racket code -