Two things are totally wrong.
This is not a proper way of working with XML. Here is my overview of the approaches you could use:
- Use
System.Xml.XmlDocument
class. It implements DOM interface; this way is the easiest and good enough if the size if the document is not too big.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^]. - Use the classes
System.Xml.XmlTextWriter
and System.Xml.XmlTextReader
; this is the fastest way of reading, especially is you need to skip some data.
See http://msdn.microsoft.com/en-us/library/system.xml.xmlwriter.aspx[^], http://msdn.microsoft.com/en-us/library/system.xml.xmlreader.aspx[^]. - Use the class
System.Xml.Linq.XDocument
; this is the most adequate way similar to that of XmlDocument
, supporting LINQ to XML Programming.
See http://msdn.microsoft.com/en-us/library/system.xml.xmldocument.aspx[^], http://msdn.microsoft.com/en-us/library/bb387063.aspx[^].
Now, about the
ListViewItem
. You miss its structure. A single instance of
ListViewItem
represents a single row of your view. Your
item.Text
represents the only the text which is shown in a leftmost cell. How about the cells shown on right? They are represented by
sub-items you completely miss. You need to iterate them under each list view item:
http://msdn.microsoft.com/en-us/library/system.windows.forms.listviewitem.subitems.aspx[
^],
http://msdn.microsoft.com/en-us/library/1x4396ba.aspx[
^].
Something like
ListView myListView = new ListView();
foreach (ListViewItem item in myListView.Items) {
foreach (ListViewItem.ListViewSubItem subitem in item.SubItems)
}
—SA