Learn XQuery |
Home:Learn XQuery: XQuery Tips and Tricks:Querying Multiple Documents How can I query all documents in a folder?You can use the fn:collection() function to query all documents in a folder. DataDirect XQuery™ allows you to specify regular expressions to match file names, provides the possibility to fetch all documents recursively in nested folders, and the possibility to sort the result. The syntax that DataDirect XQuery™ accepts for the fn:collection() function argument when dealing with retrieving files from folders is this: collection("directory_url(?option(;option)*)?")where:
More details available in the DataDirect XQuery™ product documentation. In the following example, suppose you have a number of XML files stored in the directory named books. Each of the files contains information about one book, and you want to create a single XML document that contains a list of all your books. <books> { The result would look something like this: <books> If the books directory contained sub-folders with other XML documents, then you would need to change the XQuery to: <books> { Next Question! |
Submit Your DataDirect XQuery Tip or TrickTell us your XQuery Tip or Trick – if it gets published on our site, you’ll receive a |





