Hi Allo,
I am trying to extract the value from XML by using below anonymous block,but getting errors.Please see the error report below.
Please advise.
DECLARE
x XMLType := XMLType(
'<?xml version="1.0" ?>
<abl:person>
<abl:row>
<abl:name>Jerry</abl:name>
<abl:Address>
<abl:State>UK</abl:State>
<abl:City>London</abl:City>
</abl:Address>
</abl:person>');
BEGIN
FOR r IN (
SELECT ExtractValue(Value(p),'/abl:row/abl:name/text()') as name
,ExtractValue(Value(p),'/abl:row/abl:Address/abl:State/text()') as state
,ExtractValue(Value(p),'/abl:row/abl:Address/abl:City/text()') as city
FROM TABLE(XMLSequence(Extract(x,'/person/row'))) p
) LOOP
dbms_output.put_line(r.name||r.state||r.city);
end loop;
END;
Error report -
-----------------
ORA-31011: XML parsing failed
ORA-19202: Error occurred in XML processing
LPX-00234: namespace prefix "abl" is not declared
Error at line 2
ORA-06512: at "SYS.XMLTYPE", line 301
ORA-06512: at line 2
31011. 00000 - "XML parsing failed"
*Cause: XML parser returned an error while trying to parse the document.
*Action: Check if the document to be parsed is valid.