This SQL query is used to generate the XML displayed after the clicking the
View XML button.
declare
l_XML varchar2(32767);
begin
-- force Oracle APEX to not show any HTML
sys.htp.init;
wwv_flow.g_page_text_generated := true;
wwv_flow.g_unrecoverable_error := true;
-- select XML
select xmlElement
(
"Department",
xmlAttributes( d.DEPTNO as "DepartmentNumber"),
xmlElement("Name", d.DNAME),
xmlElement("Location", d.LOC),
xmlElement
(
"EmployeeList",
(
select xmlAgg
(
xmlElement
(
"Employee",
xmlAttributes ( e.EMPNO as "employeeNumber" ),
xmlForest
(
e.ENAME as "EmpolyeeName", e.JOB as "JobTitle", e.SAL as "EmployeeSalary"
),
xmlElement ( "Commission", e.COMM )
)
)
from WWV_DEMO_EMP e
where e.DEPTNO = d.DEPTNO
)
)
).getClobVal()
into l_XML
from WWV_DEMO_DEPT d
where d.DEPTNO = 20;
-- Display HTML document
sys.owa_util.mime_header('text/xml',FALSE);
sys.htp.p('Content-Length: ' || length(l_XML));
sys.owa_util.http_header_close;
sys.htp.print(l_XML);
end;