problem with reading XML attributes and elements [message #321771] |
Wed, 21 May 2008 05:11 |
ramora
Messages: 16 Registered: November 2006 Location: hyderabad
|
Junior Member |
|
|
Hi experts,
Please help me, Its urgent..
select extract(column_value,'//C/text()').getstringval() CVal,
extract(column_value,'//O/text()').getstringval() OVal
from table(xmlsequence(extract(xmltype(
'<A A="A" T="256cff52" F="SECUF" U="admin" B="AID" C="panID" US="L_NAME" L="en" >
<T N="Table01">
<C A="D">
<C>Fid</C>
<O>AMACYR</O>
<N>null</N>
</C>
<C A="A">
<C>UID</C>
<O>null</O>
<N>256cff52</N>
</C>
</T>
<T N="Table02">
<C A="E">
<C>Fid1</C>
<O>AMACYR1</O>
<N>null</N>
</C>
<C A="F">
<C>UID1</C>
<O>null</O>
<N>256cff52</N>
</C>
</T>
</A>'),
'//A/T')));
the output is coming like below, i am getting empty for
Attributes of A and Attribute of T.
Att of A Att of T CVAL OVAL NVAL
-------- -------- ------ -------- ------------
FidUID AMACYRnull null256cff52
Fid1UID1 AMACYR1null null256cff52
Here i am getting only 2 records, but i need 4 records with the
Atrributes of corresponding child Nodes like below
Att of A. Att of T CVAL OVAL NVAL
------------------------------------------
A Table01 Fid AMACYR null
A Table01 UID null 256cff52
A Table02 Fid1 AMACYR1 null
A Table02 UID1 null 256cff52
Thanks in Advance.
|
|
|
|
Re: problem with reading XML attributes and elements [message #321794 is a reply to message #321771] |
Wed, 21 May 2008 06:12 |
ramora
Messages: 16 Registered: November 2006 Location: hyderabad
|
Junior Member |
|
|
please see below query..
select extract(column_value,'/A/@A') "Att of A",
extract(column_value,'/A/T/@A') "Att of T",
extract(column_value,'//C/text()').getstringval() CVal,
extract(column_value,'//O/text()').getstringval() OVal,
extract(column_value,'//N/text()').getstringval() NVal
from table(xmlsequence(extract(xmltype(
'<A A="A" T="256cff52" F="SECUF" U="admin" B="AID" C="panID" US="L_NAME" L="en" >
<T N="Table01">
<C A="D">
<C>Fid</C>
<O>AMACYR</O>
<N>null</N>
</C>
<C A="A">
<C>UID</C>
<O>null</O>
<N>256cff52</N>
</C>
</T>
<T N="Table02">
<C A="E">
<C>Fid1</C>
<O>AMACYR1</O>
<N>null</N>
</C>
<C A="F">
<C>UID1</C>
<O>null</O>
<N>256cff52</N>
</C>
</T>
</A>'),
'//A/T')));
|
|
|
|