Use element and attribute to create xml document : element « XQuery « XML






Use element and attribute to create xml document


File: Data.xml


File: Query.xquery

document {
  element car {
    attribute model { "B" },
    element id { 0002 },
    element name { attribute language {"en"}, "name 2"}
  }
}

Output:

<?xml version="1.0" encoding="UTF-8"?>
<car model="B">
   <id>2</id>
   <name language="en">name 2</name>
</car>

 








Related examples in the same category