woensdag 23 juni 2010

PLSQL: extract value from xmltype variable

How can i extract an value from xmltype variable in PL-SQL?
The complicating factor is the use of several namespaces in the xml content


The next codesample will demonstrate the exact syntax

create or replace procedure xmltestproc(xmlaanvraag in xmltype, result out VARCHAR2)
as
BEGIN
result:= xmlaanvraag.extract('/aanvraag/aanvraagProcedure/text()','xmlns="zuid.amsterdam/wabo/services/data/bom"' ).getstringval();
end;


More complex example. Extracting XML with mixed namespaces and

result := xmlaanvraag.extract('/aanvraag/sleutels/ns2:sleutel[ns2:sleutelType="GV"]/ns2:sleutelWaarde/text()','xmlns:ns2="zuid.amsterdam/wabo/services/data/verwijsindex" xmlns="zuid.amsterdam/wabo/services/data/bom' ).getstringval();

Geen opmerkingen:

Een reactie posten