I cannot find a way to get the values from an XML file using LINQ.
Here is the code:
Dim XMLDoc As XDocument = XDocument.Load(XMLPath)
Dim query = From ex In XMLDoc.Descendants.Elements("DSServer")
Select New With
{
.svrname = ex.Element("ServerName"),
.BG = ex.Element("IsBG")
}
For Each t In query
MsgBox(t.svrname.Value.ToString + " " + t.BG.Value.ToString)
Next
And here is the XML
<?xml version="1.0" standalone="yes"?>
<DSPaths xmlns="http://tempuri.org/DSPaths.xsd">
<DSServer>
<ServerName>test1Name</ServerName>
<ServerIP>test1</ServerIP>
<ServerPath>test1</ServerPath>
<Destination>test1</Destination>
<IsBG>true</IsBG>
</DSServer>
<DSServer>
<ServerName>test2Name</ServerName>
<ServerIP>test2</ServerIP>
<ServerPath>test2</ServerPath>
<Destination>test2</Destination>
<IsBG>true</IsBG>
</DSServer>
</DSPaths>
What am I doing wrong?
The code does not return anything...