Output pretty xml
-
select XMLSERIALIZE(Document l_msg as CLOB INDENT SIZE = 2)
-
into l_tmp
-
from dual;
-
dbms_output.put_line(l_tmp);
Loop through xml results
-
/* LOOP through the Results*/
-
l_result_cnt := 1;
-
WHILE l_xmlresp.existsNode('//AccessReq:QueryMessage/AccessReq:body/AccessReq:Results/AccessReq:Result[' || to_char(l_result_cnt) || ']',v_ns_map) = 1
-
LOOP
-
SELECT extract(l_xmlresp, '//AccessReq:QueryMessage/AccessReq:body/AccessReq:Results/AccessReq:Result[' || to_char(l_result_cnt) || ']', v_ns_map)
-
INTO l_xmlsingleresult
-
FROM dual;
-
-
-
l_result_cnt := l_result_cnt + 1;
-
end loop;
Get some data
-
SELECT
-
extractvalue(l_xmlsingleresult, '/AccessReq:Result/AccessReq:Identifier', v_ns_map),
-
extractvalue(l_xmlsingleresult, '/AccessReq:Result/AccessReq:SystemName', v_ns_map),
-
extractvalue(l_xmlsingleresult, '/AccessReq:Result/AccessReq:Action', v_ns_map),
-
extractvalue(l_xmlsingleresult, '/AccessReq:Result/AccessReq:User/AccessReq:Identifier', v_ns_map),
-
extractvalue(l_xmlsingleresult, '/AccessReq:Result/AccessReq:Role/AccessReq:Identifier', v_ns_map),
-
extractvalue(l_xmlsingleresult, '/AccessReq:Result/AccessReq:OriginatingRequest/AccessReq:Identifier', v_ns_map),
-
extractvalue(l_xmlsingleresult, '/AccessReq:Result/AccessReq:OriginatingRequest/AccessReq:System', v_ns_map)
-
INTO
-
l_identifier,
-
l_systemName,
-
l_Action,
-
l_User,
-
l_Role,
-
l_OriginatingReqID,
-
l_OriginatingReqSys
-
FROM dual;
Outputting XML
Convert VARCHAR2 into XML Safe VARCHAR2
HTF.ESCAPE_SC(l_str)
Copied from other page
-
set serveroutput on
-
DECLARE
-
resp XMLTYPE := XMLTYPE('<?xml version="1.0" encoding="UTF-8"?>
-
<soapenv:Envelope xmlns:soapenv="http://www.w3.org/2003/05/soap-envelope">
-
<soapenv:Body><if:sayGreetingsResponse xmlns:if="http://xml.bnz.co.nz/filetransferadministrationservice/TestIF">
-
<if:output>Hello Bhooma. Thank you for using this service.</if:output></if:sayGreetingsResponse></soapenv:Body>
-
</soapenv:Envelope>');
-
-
xout varchar2(300);
-
BEGIN
-
SELECT extractvalue( resp
-
, '/soap:Envelope/soap:Body/if:sayGreetingsResponse/if:output'
-
, 'xmlns:soap="http://www.w3.org/2003/05/soap-envelope", xmlns:if="http://xml.bnz.co.nz/filetransferadministrationservice/TestIF"' )
-
INTO xout
-
FROM dual;
-
-
dbms_output.put_line('### '||xout||' ###');
-
-
-
END;
-
/
XMLElement to produce safe XML
-
select
-
xmlelement("msg",
-
xmlattributes( 'SOMENAMESPACE' as "xmlns"),
-
xmlelement("resourse_name",p_resourse_name),
-
xmlelement("resourse_id",p_resourse_id),
-
xmlelement("operations",p_operations),
-
xmlelement("num_unbatched_events",p_num_unbatched_events),
-
xmlelement("payload",p_payload)
-
)
-
into x_xml
-
from dual;
XMLForest to produce safe XML
-
select xmlforest(xmlforest(
-
p_resourse_name as "resourse_name",
-
p_resourse_id as "resourse_id",
-
p_operations as "operations",
-
p_num_unbatched_events as "num_unbatched_events",
-
p_payload as "payload"
-
) as "msg")
-
into x_xml
-
from dual;
RJM Article Type
Quick Reference