Skip to content

QueryXml

Executes an XQuery against the repository and returns the results as an array of XML nodes.

1
$XmlRepository.QueryXml(xquery: string, parameters: object, collection: string):Array<Xml>

Parameters

string xquery
    The XQuery expression to execute against the database. The syntax of the query is detailed. More information can be found on the XQuery standard page.

object parameters
    An object containing parameters to bind to the XQuery expression.

string collection
    The name of the collection to query. If not specified, the domain database is queried.

Returns

An array of Xml nodes representing the results of the XQuery. Returns an empty array if the query yields no results.

Remarks

See XML+Database for further information about domain and process databases.

Find all customers:

1
2
var results = $XmlRepository.Query('//Customer');
$Xml.InnerXml( 'Customer', results.join() );

Find customer by ID:

1
2
3
4
var results = $XmlRepository.Query('//Customer[Id=$id]', {
   id : $Xml.Evaluate('CustomerId')
 });
$Xml.InnerXml( 'Customers', results.join() );

Info

To query a process database, use the ,collection, keyword and provide the database's GUID.

For process databases, you can obtain the GUID using ,$Instance.ProcessId,.

Querying a process database:

1
2
3
4
var results = $XmlRepository.QueryXml('collection("49551ed3-6229-408a-aaaa-eb510463acad")//Customer[Id=$id]', {
id : $Xml.Evaluate('CustomerId')
});
$Xml.InnerXml( 'Customers', results[0].Evaluate('Id') );

See Also