Use doc() function to load XML document : doc « XQuery « XML






Use doc() function to load XML document

File: Data.xml


<?xml version="1.0"?>
<bib>
  <book year="1988">
    <author>
      <last>A</last>
      <first>B</first>
    </author>
  </book>
  <book year="2004">
    <author>
      <last>E</last>
      <first>F</first>
    </author>
  </book>
</bib>


File: Query.xquery

doc("Data.xml")/bib/book

Output:

<?xml version="1.0" encoding="UTF-8"?>
<book year="1988">
    <author>
         <last>A</last>
         <first>B</first>
    </author>
  </book>
<book year="2004">
    <author>
         <last>E</last>
         <first>F</first>
    </author>
  </book>

 








Related examples in the same category

1.doc() funciton in for loop
2.Use doc() function to load xml docuCt
3.Load children