I have data XML format like this.
<"id=1">
<"a">Test<"/a">
<"b">Test2<"/b">
<"c">Test3<"/c">
How to get value C in field XMLData?
*value C is Test3
How to get value C in field XMLData?
As mentioned by @Wernfried Domscheit your xml
doesnot look correct. See below one way to do it:
create table traptabclob(testclob clob);
/
insert into traptabclob
values
('<?xml version="1.0" encoding="UTF-8"?>
<DCResponse>
<id>
<Field key="a">Test</Field>
<Field key="b">Test2</Field>
<Field key="c">Test3</Field>
</id>
</DCResponse>');
/
Query:
SELECT
EXTRACTVALUE(xmltype(testclob), '/DCResponse/id/Field[@key="c"]') col1
FROM traptabclob;
Output:
Col1
----
Test3
Edit:
Thank you for your reply, my data doesn't has tag
<?xml> version="1.0"....
my data just like<row> id="1"><a>Test</a><b>Test2</b></row>
, it is looks likexml
type but i dont know this isxml
type or not. Thank you
Please see that i have just given an example of valid xml file which contains usually <?xml> version="1.0"....
. However issue with your xml code is putting tags in "
. See below how it works:
create table traptabclob(testclob clob);
insert into traptabclob values('
<id>
<a>Test</a>
<b>Test2</b>
<c>Test3</c>
</id>');
Query:
SELECT EXTRACTVALUE(xmltype(testclob), '/id/c') col1
FROM traptabclob ;
Output:
Col1
----
Test3