Advanced XPath Features

Advanced XPath Features


For more complex scenarios, XPath provides regular expressions, variable assignments, and special functions to manipulate and evaluate XML data dynamically.

This section covers these advanced features.

Working with regular expressions in XPath

Using variables in XPat

Working with regular expressions in XPath

You can use regular expressions with Xpath, if you use the matches Xpath function. This expression checks the variable, MyVariable:

matches($MyVariable, "^(DIN|ISO) A[3-5]$")

 

The regular expression above tests, if the variable:

starts with either 'DIN' or 'ISO'

then a space and the letter 'A'

finish with 3, 4 or 5

 

You can use the expression in IF- and select elements to let the output depend on the result of a test.

 

Remember, that you can combine the XPath functions, and that there are many other functions not mentioned here. This appendix hopefully gives you an idea of how strong a tool this is. You can e.g. refer to this link for additional information: https://www.w3schools.com/js/js_regexp.asp


Using variables in XPath
XPath is a strong tool so you can even use variables in your XPath expressions. 
More detailed information about variables can be found here

 

    • Related Articles

    • XPath

      In InterFormNG2, you use the language XPath for referencing data from the XML file. There are many sources of information if you want to learn more about XPath, but you can also simply read the few examples below to get a good idea of how it can be ...
    • Node Existence & Conditions

      XPath allows you to verify the existence of nodes, check if they contain data, count occurrences, and ignore namespaces. This section covers essential techniques for validating and filtering XML elements. Calculating the sum of nodes Counting ...
    • Advanced Utilities workflow components

      The Advanced Utilities workflow components are as follows: Append to zip archive. Appends the payload to a zip file. The zip file will be created, if the referenced zip file does not exist. Attachment to payload. Takes a named attachment, removes it ...
    • XPath wizard

      When you in InterFormNG2 insert a value in a field, then you for most have these options: 1.You can insert a fixed text. 2.You can type a dynamic XPath expression where you need to remember each XPath function and the matching parameters. 3.For some ...
    • Set one workflow variable

      The advanced set meta data workflow component, Set one workflow variable, sets/defines a workflow variable. This can be used later in the workflow and also in a template in the designer. The variable can be referenced in XPath expressions with a ...