Looping through an XML document
Posted on 2004-04-04
I have an XML document similar to the one below that I need to process and display in a windows fomm using a combination of tree-view and list view controls in C#. The element <Company> is the only one that I can guarantee will come in the same standard format each time the XML is created and I need to display that separately on the windows form. The rest of the elements can change and could possibly more nested elements within them. What is the best way to loop through such an XML document and display the contents? I am a novice XML user so any help will be appreciated. Also, what is the determining factor in using the XML document object Vs XmlTextReader? Thanks.
<?xml version="1.0" encoding="utf-8"?>
<First Name>Peter</First Name>
<Last Name>Pan</Last Name>
<First Name>John</First Name>
<Last Name>Doe</Last Name>