How can I avoid the XPath element not found error/exception during calling XML Get single node action
XML Example:
<Xml>
<data>
<Name>name1</name>
<gender>femail</gender>
<data>
<data>
<Name>name2</name>
<data>
</Xml>
where XPath try to find gender
How can I avoid the XPath element not found error/exception during calling XML Get single node action
XML Example:
<Xml>
<data>
<Name>name1</name>
<gender>femail</gender>
<data>
<data>
<Name>name2</name>
<data>
</Xml>
where XPath try to find gender
Hi @Murad Mahmoud ,
The XML seems to have few issues, I've edited it:
<xml>
<data>
<name>name1</name>
<gender>femail</gender>
</data>
<data>
<name>name2</name>
</data>
</xml>
Now, with any XML its always a best practice to check if the XML is valid or not using the XML: Validate XML Document Action.
And the XPath which was able to successfully retrieve it is this:
//gender
Now onto the concept of Error Handling, encase the entire set of Actions within a Try Catch like so:
The errors are handled gracefully, and the error details are "caught" in the Catch Action.
Kind Regards,
Ashwin A.K
Thanks for answering, this is the requirements, the XML is dynamic and sometimes the gender element appears in the XML, and other time did not appear depending on the user answer to show or high the gender, I can not control the XML output
In that case, all we can do is encase our Actions within Try Catch and proceed with that.
Kind Regards,
Ashwin A.K
The other problem is that will result in performance issues since try-catch is RAM and Processor consumer for large XML file
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.