How do I add comment to an XML string
This example demonstrates adding one or more comments in the given XML
In the solution shown below, the comments are added in the XML at the specified path using "xmlComment" command. If the path does not exists, the comments are not added and the same XML is returned.
Solution:
# | Command | Target | Value |
---|---|---|---|
Add comments to an XML string for the given two paths | |||
1 | xmlComment | <insurance><age>45</age><income>20000</income><zipcode>08817</zipcode><result>You are eligible for a subsidy.</result></insurance>|| {/insurance/age,Provide Age} || {/insurance/income,Provide Income} | XML_with_comments |
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.