How do I validate the syntax of the XML string.
This example demonstrates validating whether the syntax of XML string is valid or not.
In the solution shown below, the syntax of the XML string is validated using "xmlAssertValidityGetParserError" command. If the XML string is valid then the command returns the result as '1', else returns the error message.
Solution:
# | Command | Target | Value |
---|---|---|---|
Validate the syntax of XML string | |||
1 | xmlAssertValidityGetParserError | <insurance><age>45</age><income>20000</income><zipcode>08817</zipcode><result>You are eligible for a subsidy.</result></insurance> | XMLValidationResult |
Tips, Tricks, Gotchas & Best Practices:
- 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.