 CREATE TABLE CountryXML OF XMLType;

 INSERT INTO CountryXML
 (SELECT XMLElement("Country",
   XMLAttributes(code AS "Code",
                 population AS "Population"),
   XMLElement("Name",name),
   (SELECT XMLElement("Capital",
             XMLForest(name AS "Name",
                       population AS "Population"))
    FROM city
    WHERE country=country.code
      AND city.name=capital))
 FROM country);
