I am trying to retrieve the attribute "value" if "key" = PublicAddresses[PRIMARY][0]. I am very new at this and I am trying to learn VB.Net as I go.
Here is my xml document layout
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE preferences SYSTEM "http://java.sun.com/dtd/preferences.dtd">
<preferences EXTERNAL_XML_VERSION="1.0">
<root type="system">
<map/>
<node name="Level1">
<map/>
<node name="current">
<map/>
<node name="PublicIdentity">
<map>
<entry key="PublicAddresses[PRIMARY][0]" value="192.168.1.1"/>
<entry key="PublicAddresses[SECONDARY][0]" value="192.168.1.2"/>
</map>
</node>
</node>
</node>
</root>
</preferences>
Here is what I have come up with, very spaghetti like:
Imports System
Imports System.Xml
Module Module1
Sub Main()
Dim XmlDoc As XmlDocument = New XmlDocument
XmlDoc.Load("prefs.xml")
For Each Element As XmlElement In XmlDoc.SelectNodes("//*")
For Each Attribute As XmlAttribute In Element.Attributes
If Attribute.Name = "value" Then
Console.WriteLine("{0}", Attribute.Value)
End If
Next
Next
End Sub
End Module