Reading XML when node does not exist

Hi All, I'm attempting to read a segment of an XML file into a structure, but the file itself isn't uniform and I need a way for the XmlElement_SelectSingleNode to handle the "undefined" result.

For instance, if the member node is as follows:





I need a way for XmlElement_SelectSingleNode to interpret not finding the <position> node as an empty position node containing ""

The most immediate idea is to have an error handler. The alternative is to do some pre-processing of the file and look for things that are malformed and adjust the input appropriately.

In the same position. I don't think working with catching the exception would be acceptable, I will try if 'translating' to json and then to reserialise to a structure could work for me.

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.