The {{Function|Database|db:add}} and {{Function|Database|db:put}} functions can also be used to add new XML documents to the database. The following example query uses the internal XML parser and adds all files to the database <code>DB</code> that are found in the directory <code>2Bimported</code>:
<syntaxhighlight pre lang="'xquery"'>
for $file in file:list("2Bimported")
return db:add('DB', $file, '', map { 'intparse': true() })
</syntaxhighlightpre>
=HTML Parser=
3. On the first tab, you can see an XML snippet like this:
<syntaxhighlight pre lang="xml">
<dependency>
<groupId>org.ccil.cowan.tagsoup</groupId>
<version>1.2.1</version>
</dependency>
</syntaxhighlightpre>
4. Insert the XML fragment into the <code><dependencies></code> element of your project’s <code>pom.xml</code> file.
The [[HTML Module]] provides XQuery functions for converting HTML to XML. In addition, all functions that accept [[Options#Parsing|Parsing Options]] can be used as well to convert HTML:
<syntaxhighlight pre lang="'xquery"'>
fetch:doc("index.html", map {
'parser': 'html',
'htmlparser': map { 'method': 'xml', 'nons': true() }
})
</syntaxhighlightpre>
=JSON Parser=
In addition, all functions that accept [[Options#Parsing|Parsing Options]] can be used as well to convert JSON. The following query converts a JSON string to an XML document, using the conversion format {{Code|[[JSON Module#Basic|basic]]}}:
<syntaxhighlight pre lang="'xquery"'>
db:create('json-db', '{ "key": "value" }', 'example.json', map {
'parser': 'json',
'jsonparser': map { 'format': 'basic' }
})
</syntaxhighlightpre>
=CSV Parser=
In addition, all functions that accept [[Options#Parsing|Parsing Options]] can be used as well to convert CSV. In the following, all CSV files from a directory are added to a database, with the first line of each file interpreted as column header:
<syntaxhighlight pre lang="'xquery"'>
for $file in file:list("2Bimported", false(), "*.csv")
return db:add("csv-db", $file, "", map {
'csvparser': map { 'header': true() }
})
</syntaxhighlightpre>
=Changelog=