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