Hello Erik,
Welcome to Visual Basic Language forum!
I think the most difficult part in this problem is the namespace of the XML nodes and attributes. In LINQ to XML, to retrieve certain XElement or XAttribute, we need to set their namespace correctly. For detail, please see http://msdn.microsoft.com/en-us/library/bb387093.aspx.
Here are some sample codes to retrieve the Name, Value elements and the type attribute of the Value element: (The text is loaded from a txt file)
============================================================================
Dim reader = New StreamReader("XML.txt")
Dim text = reader.ReadToEnd()
reader.Close()
Dim ns As XNamespace = "urn:schemas-microsoft-com:xml-analysis"
Dim xsi As XNamespace = "http://www.w3.org/2001/XMLSchema-instance"
Dim xsd As XNamespace = "http://www.w3.org/2001/XMLSchema"
Dim root = XElement.Parse(text)
Dim name As XElement = Nothing
Dim value As XElement = Nothing
Dim type As XAttribute = Nothing
For Each element In root.Elements(ns + "Parameter")
name = element.Element(ns + "Name")
Console.WriteLine("Name: {0}", name.Value)
value = element.Element(ns + "Value")
type = value.Attribute(xsi + "type")
Console.WriteLine("Value: {0} Type:{1}", value.Value, type.Value.Replace("xsd", xsd.ToString()))
Next
============================================================================
If you have any questions, please feel free to let me know.
Have a great day!
Best Regards,
Lingzhi Sun
MSDN Subscriber Support in Forum
If you have any feedback on our support, please contact msdnmg@microsoft.com
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.