Parsing Through XML with Varying Tags

I am working on a project where we will receive a batch file in XML format for an internal process. I’ve read some of the other forum posts on how to handle XML files, and I think the easiest way is to use the built in deserialize functions.

Unfortunately, all the examples and explanations have been for files that have consistent tags for each records. The files we receive will have varying information depending on the type of record. Each record will be separated within a tag, lets say tag “a”.

How can I iterate through this file and get the information without knowing which tags each section is going to contain?

You can check if the xelement has child elements or attributes and based on that you can loop through the xml for the required values. But it is a bit complicated process and needs to be very keen on the process which you are trying to do

1 Like