Parse XML with Namespaces and Iterate

There are several forum posts talking about parsing XML files with namespaces, and others that talk about iterating through child data elements, but I can’t seem to get either to work with our current data set. The attached XML is a SOAP envelope response to an API call that has three headers (Response_Criteria, Request_Filter, and Response_Results), and then has some number of Response_Data blocks (in this case, 2 blocks - but in the live data there will be 999 blocks).

At a minimum, we need to get the File_Content value from each Response_Data block.
Ideally we would also like to be able to retrieve the correlated Employee_ID that goes with that Response_Data block.
In a perfect world, we would be able to get all data elements, so that each iteration of the Response_Data would have the header data included.

This is the XML file with the Response_Data blocks collapsed for brevity:

This is what the Response_Data block looks like, expanded:

This is as far as I’ve gotten but I can’t figure out what combination of namespaces and .NET strings to use to get the data out:

data.xml (3.8 KB)

@pumrum
Find some starter Help:

  • retrieving the two responseData elements
  • reading out an element with name and value
  • reading out an attribute with name and value
  • dynamic reading all leaf elements with name and value, adding this to a datatable

grafik
grafik

Find Xaml here:
pumrum.xaml (12.2 KB)

Let us know your feedback

4 Likes

Wow - that is excellent, thank you! I am going to take some time to dissect and understand exactly what you did here so I can learn from it, but at first glance it seems to be exactly what I was trying to accomplish.

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.