| '''Errors'''
|{{Error|BXDB0002|XQuery Errors#BaseX Errors}} The addressed database does not exist or could not be opened.
|-
| '''Examples'''
| Export all files as text:<br/>
<pre class="brush:xquery">
db:export("DB", "/home/john/xml/texts", map { 'method': 'text' })
</pre>
The following query can be used to export parts of the database:
<pre class="brush:xquery">
let $target := '/home/john/xml/target'
for $doc in db:open('DB', 'collection')
let $path := $target || db:path($doc)
return (
file:create-dir(file:parent($path)),
file:write($path, $doc)
)
</pre>
|}