VB.NET Read XML Values

cossette_maria

New Member
i have been trying to find an "elegant" solution to my problem but so far i was unable to make it work the way i want. What I am trying to do is:\[code\]<profile id="Baseline"> <package package-id="Software1" /> <package package-id="Software2" /> <package package-id="Software3" /></profile><profile id="OLD_Profile"> <depends profile-id='Baseline' /> <package package-id="Software1" /> <package package-id="Software2" /> <package package-id="Software3" /></profile>\[/code\]This is the XML Code I want to read.What I am trying to do is.Read each profile ID Tag.. and then for each profile ID i want to read the sub tags.. like "package package-id" and "depends profile-id"I tried several approaches but they are all ugly and buggy.Thank you for your helpedit:Think i got it to work the way I want:\[code\] Dim doc As New XmlDocument doc.Load("C:\profiles.xml") Dim hosts As XmlNodeList = doc.GetElementsByTagName("profile") For Each n As XmlElement In hosts For Each n2 As XmlElement In n Debug.Print(n2.GetAttribute("package-id").ToString()) If Not n2.GetAttribute("profile-id").ToString() = Nothing Then Debug.Print(n2.GetAttribute("profile-id").ToString()) End If Next Next\[/code\]This seems to work fine.. i bet there is a more elegant solution but it works :)
 
Back
Top