Quantcast
Channel: VBForums
Viewing all articles
Browse latest Browse all 42225

Read XML and add it to a listView with multi columns

$
0
0
I use this code :

Code:

System.Xml.XmlDocument loadDoc = new System.Xml.XmlDocument();
loadDoc.Load(Application.StartupPath + "\\servers.xml");
foreach (System.Xml.XmlNode ipNode in loadDoc.SelectNodes("/users/profile"))
        {
            listView1.Items.Add(ipNode.Attributes["ip"].InnerText);
        }
foreach (System.Xml.XmlNode serverNode in loadDoc.SelectNodes("/users/profile"))
        {
            listView1.Items[listView1.Items.Count - 1].SubItems.Add(serverNode.Attributes["server"].InnerText);
        }
foreach (System.Xml.XmlNode countryNode in loadDoc.SelectNodes("/users/profile"))
        {
            listView1.Items[listView1.Items.Count - 1].SubItems.Add(countryNode.Attributes["country"].InnerText);
        }
    }

and this is the xml :

PHP Code:

<?xml version="1.0"?>
<users>
     <profile ip="212.23.122.45" server="server name1" country="D">
    </profile>
 <profile ip="212.22.123.122" server="server name2" country="D">
    </profile>
</users>


Nothing shows up in my listView , any help whould be great . Thank you .

Viewing all articles
Browse latest Browse all 42225

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>