XML from Data Base Examples tutorial
Making an XML element with nested XMLAGG() function XML element with XMLAGG() function call as parameter

## Example 8

This example produces an 'Emp' element with attribute 'Title' and a list of all employees having the title 'Sales Representative' as element content.

    select XMLELEMENT ('Emp', XMLATTRIBUTES ("Title"),
                              XMLAGG (XMLELEMENT ('Name', "FirstName", ' ', "LastName")))
    from "Demo"."demo"."Employees"
    where "Title"= 'Sales Representative';