I am trying to parse this XML in PL/SQL
I think there are two things you have wrong here:
Firstly, your XPath expression //@GovernmentCode/
is wrong. It should not have a trailing /
, and you don't want the @
either because GovernmentCode
is an element, not an attribute.
Secondly, you must specify the XML namespace declaration in your call to EXTRACTVALUE
as well as in your call to EXTRACT
.
Making these changes leaves you with the following code. I gave it a quick test, and it seemed to work:
SELECT EXTRACTVALUE (VALUE (xml_list), '//GovernmentCode', 'xmlns="http://www.irs.gov/efile"') AS SysID
INTO lv_transid
FROM TABLE (
XMLSEQUENCE (
EXTRACT (in_xmlclob, '/AckTransmission/Acknowledgement',
'xmlns="http://www.irs.gov/efile"'))) xml_list;