Skip to content

$XmlRepository.QueryXml

Overview

XmlNode[] $XmlRepository.QueryXml ( xquery )
Performs an xquery on repository and returns the results as xml node array.

Arguments

String xquery Specifies the query to perform on the database. The syntax of the query is quite detailed. More information can be found on xquery standard page.

object parameters Specifies the binding parameters on xquery string.

Remarks

If query does not return any result than return value is empty array.

Examples

Find all customers

var results = $XmlRepository.QueryXml('//Customer');
$Xml.InnerXml( 'Customer', results[0].Evaluate('Id') );
Find customer by id
var results = $XmlRepository.QueryXml('//Customer[Id=$id]', {
   id : $Xml.Evaluate('CustomerId')
 });
$Xml.InnerXml( 'Customers', results[0].Evaluate('Id') );
Basically, you query your domain database.

If you want to query the database of a process, you can use the collection keyword. You have to give the name of the database which is basically a GUID. For process databases, you can have that GUID by $Instance.ProcessId.

Querying another database

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