Skip to content

How do I check whether the given path exists in the given XML

This example demonstrates validating whether the specified path exists in the given 'XML_STRING'

In the solution shown below, the XML Path is validated using "xmlAssertPathExists" command. If the XML path provided is valid then the command returns 1, else returns 0.

Solution:

# Command Target Value
To check if the path exists in the input XML string
1 xmlAssertPathExists <insurance><age>45</age><income>20000</income><zipcode>08817</zipcode><result>You are eligible for a subsidy.</result></insurance> || /insurance/age isPathExists

Tips, Tricks, Gotchas & Best Practices:  

  • The XML should be valid and encoded in "UTF-8" format.
  • As a best practice, it is always advisable to define the variable names without any spaces and if you want to differentiate the words, use underscores.


Feedback and Knowledge Base