I have a directory called auction containing a list of xml files.
How can I create a script to iterate through each file and perform operations. I am trying to use collection()
, but it is not working.
for $relpath in collection("auction")
for $b in $relpath/people/person[@id = "person0"] return $b/name/text()
Please help.
More info will be provided if required
The answer was found here: https://groups.google.com/forum/#!topic/zorba-users/8W2xOQ2j0Vw
Modified it to suit my purposes. An example is as follows:
import module namespace file="http://expath.org/ns/file";
for $relpath in file:list("auction", fn:true(), "*.xml")
let $abspath := fn:concat("auction/", $relpath)
for $b in doc($abspath)/people/person[@id = "person0"] return $b/name/text()
Firstly, the module needs to imported to be used which contains the list function, which shows all the contents. Then the iterations can go through each file and open it as a document. However, the name of the folder needs to concatenated with the filename