Home » Developer & Programmer » JDeveloper, Java & XML » Extract Attribute Values? (Oracle 10 g ,windows)
Extract Attribute Values? [message #344804] Mon, 01 September 2008 05:19 Go to next message
manickam
Messages: 9
Registered: June 2005
Location: chennai
Junior Member

While executing the below query i get the output as
"B = "12""

SELECT
extractvalue(value(x) ,'/C')
FROM
TABLE(XMLSequence(extract(xmltype
('<A>
<C> B = "12" </C>
</A>'),'/A/C')))x


But my actual requirement is to retireve the value "12"

How to achieve it,

I tried out the below query but its not working,

SELECT
extractvalue(value(x) ,'/C/@b')
FROM
TABLE(XMLSequence(extract(xmltype
('<A>
<C> B = "12" </C>
</A>'),'/A/C')))x


Re: Extract Attribute Values? [message #344823 is a reply to message #344804] Mon, 01 September 2008 05:51 Go to previous messageGo to next message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
You got the correct result, the value of element C is 'B = "12"'.
Now if you want to extract some part of this value (which is no more a XML question) use substr+instr or regexp functions.

Regards
Michel
Re: Extract Attribute Values? [message #344837 is a reply to message #344804] Mon, 01 September 2008 06:17 Go to previous messageGo to next message
manickam
Messages: 9
Registered: June 2005
Location: chennai
Junior Member

Consider this below xml for eg,
<A>
<C> B = "12" D = "13"</C>
<C> B = "14" D = "15"</C>
</A>


Is there any method to project the above xml as below with out using substr or instr functions?

B D

12 13
14 15
Re: Extract Attribute Values? [message #344846 is a reply to message #344837] Mon, 01 September 2008 07:02 Go to previous message
Michel Cadot
Messages: 68625
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
There is no XML function way as once you extract the values (those between <C> and </C>) it is no more XML.
So you have to use either substr/instr or regexp functions.

Regards
Michel
Previous Topic: How to use "if" in XML?
Next Topic: PROBLEM WHILE USING XMLTYPE AS INPUT PARAMETER
Goto Forum:
  


Current Time: Fri Mar 29 01:11:30 CDT 2024