Hi I am new to BaseX and I am trying to read a bunch of XML files from a folder. After reading those files I will output the data into the database table (some RDBMS). But I am lost as to where to start as I am not able to find much tutorials about working with BaseX. I had searched on internet but still not much help. Can someone please help me with this.
Thanks in advance.
Use CREATE DB yourdbname /path/to/folder
to create a database containing all documents in this folder. To access the documents, use collection("yourdbname")
. If you need to access a particular file, use collection("yourdbname/document.xml")
.
To query all these files, you could do something like
for $document in collection("yourdbname")
return string-join((
document-uri($document),
": ",
xs:string(count($document//*))
))
which will return all document paths with their respecting node counts.
For further reading, have a look at the getting started section in BaseX' documentation, you should be able to find all needed information in there. For storing data in an RDBMS using SQL, have a look at the SQL module, there are also some examples included.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With