FRENDS⁴ Common Components : Frends.Common.Data.QueryData.QueryXML

This task takes an XML document as an input and then executes the given XPath query to that document returning the result.

Input Parameters

  • InputXML
    • The document that the query is executed against. Input can be given in the following formats:
      • XML as a C# String
      • C# XmlDocument
  • XPath
    • The XPath query that is to be executed for this object.
    • The XPath query must be written in a correct format. For more information about XPath see W3Schools XPath.

Options Parameters


  • ReturnAsList
    • Return result as a list
  • ThrowErrorOnMissingNode
    • Throw NullReferenceException if XPath does not return a value.
    • If false and no value found result will be empty string.

Output Result

  • String
    • A string containing the first result node value of the XPath query.
  • List of Strings
    • A list of all result node values.

Example Usage

For example calling this task, with the following JSON query:

/bookstore/book[1]/title

and a C# XML String:

<bookstore>
  <book category="COOKING">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>
    <year>2005</year>
    <price>30.00</price>
  </book>
</bookstore>

Will produce the following result:

Everyday Italian

Errors

The task will return an exception The input data was not recognized. Supported formats are XML string and XMLDocument. if the input data could not be read correctly.

The task will return an exception NullReferenceException if the XPath did not match any elements and ThrowErrorOnMissingNode is true.