Skip to content

Get Specified Value From XML: GETXMLVALUEHANDLER

The Get Specified Value From XML function retrieves a specified value from an XML file. This function is particularly useful for working with structured XML data and extracting values dynamically for automation workflows.

Example Usage: Let’s say you have an XML file that stores book details, and you need to extract the title of a book. Instead of manually searching through the XML, you can use Get Specified Value From XML function to fetch the data instantly.

Here’s an example XML snippet:

scrn-example-usage-get-specified-value-from-xml
Sample XML Data

To retrieve the title (Midnight Rain), you need to provide the key “catalog.book.2.title”. The dot (.) notation helps navigate the XML hierarchy, and the indexing (1) is used when multiple entries exist at the same level.

Steps to Configure:

  1. Select Set a Variable Value from the Action dropdown.
  2. In the Element Key field, enter a variable name to store the extracted value (e.g., XMLValue).
  3. In the Parameter section, click Form and select Functions from the dropdown.
  4. Choose Get Specified Value From XML from the list of functions.
  5. Provide the following details:
    • XML Data: Enter the XML content or reference a variable containing XML data using the syntax: ${Variable Name}

Note: If you are referencing XML data using a variable, ensure that the variable is already defined before using it in the function.

    • Key: Define the key to fetch the desired XML value (e.g., catalog.book.2.title).
  1. Click Save.

Note: While the steps for adding an action command are identical in both views, the display of the steps changes:

scrn-get-specified-value-from-xml-tabular-view
Tabular View
scrn-get-specified-value-from-xml-card-view
Card View
  • If the XML content is large, store it in a variable and reference it instead of entering raw data.
  • Use dot (.) notation to navigate the XML structure.
  • Use indexing when multiple elements exist at the same level.

Example Workflow Using “Get Specified Value From XML” Function:

The following screenshot demonstrates how multiple values can be extracted from an XML file using the Get Specified Value From XML function in HuLoop.

Each SET (Set a Variable Value) command retrieves a specific XML value and stores it in a corresponding variable (e.g., output_author, output_title, output_genre). These extracted values are then validated using VERIFYEQUAL (Verify Equality Of Two Values) command to ensure correctness.

Example Workflow Using the ‘Get Specified Value From XML’ Function

Expected Outcome on execution:

  • The specified value from the XML is extracted and stored in the variable defined in the Element Key.
  • The extracted data can be used dynamically in subsequent automation steps using the syntax ${Variable Name}.

Back To Top