Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <HostCollection>
- <ApplicationInfo />
- <Hosts>
- <Host>
- <Name>Test</Name>
- <IP>192.168.1.1</IP>
- </Host>
- <Host>
- <Name>Test</Name>
- <IP>192.168.1.2</IP>
- </Host>
- </Hosts>
- </HostCollection>
- Dim doc As XmlDocument = New XmlDocument()
- doc.Load("hosts.xml")
- Dim nodeList as XmlNodeList
- nodeList = doc.SelectNodes("/HostCollectionInfo/Hosts/Host")
- XPathDocument xpathDoc;
- using (StreamReader input = ...)
- {
- xpathDoc = new XPathDocument(input);
- }
- XPathNavigator nav = xpathDoc.CreateNavigator();
- XmlNamespaceManager nsmgr = new XmlNamespaceManager(nav.NameTable);
- XPathNodeIterator nodes = nav.Select("/HostCollection/Hosts/Host", nsmgr);
- while (nodes.MoveNext())
- {
- // access the current Host with nodes.Current
- }
Add Comment
Please, Sign In to add comment