Skip to Main Content

Database Software

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Parsing XML attributes

GregorMMar 8 2012 — edited Mar 10 2012
Hi.

I have the following example of XML structure :

create table xxx (xmlval xmltype);
insert into xxx values (xmltype('<?xml version="1.0" encoding="utf-8"?> <Records> <Card P1="10" P2="20" /> </Records>'));

I have written the following code :


declare
lx_xml_node xmltype;
l_str varchar2(100);
begin
select e.xmlval.extract('/Records/Card[1into lx_xml_node from xxx e;
select lx_xml_node.extract('/@Card/P1').getStringVal() into l_str from xxx e;
dbms_output.put_line(l_str);
end;

The problem is I cant get the value of P1 attibute (l_str IS NULL). Is there a way to extract P1 and P2 attribute from xml node? Any help or hint appreciated.

Thanks.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Apr 7 2012
Added on Mar 8 2012
10 comments
1,302 views