I have the following code that loads an XML file into a datatable (I went this route because I do not know how to query XML directly). I want to use the Select method to return a row where “age = 72”. However, I can’t seem to get this to work. Any ideas? Also, if there is a better way to search through a datatable for specifc values that would not require iterating through the whole table to get the results please let me know.
Imports System.Xml
Module Module1
Sub Main()
Dim settings As New XmlReaderSettings
settings.IgnoreWhitespace = True
settings.IgnoreComments = True
Dim xmlFile As XmlReader
xmlFile = XmlReader.Create("..\..\XMLFile1.xml", settings)
Dim ds As New DataSet
Dim dt As New DataTable
ds.ReadXml(xmlFile)
dt = (ds.Tables("Age"))
dt.TableName = "MainRMDTable"
Dim dtValue() As DataRow
Dim filter As String = "age = 72"
dtValue = dt.Select(filter)
Console.ReadLine()
End Sub
End Module
Update with the solution.
I needed to put single quotes around 72.
Visit this page
http://zeusarticles.com/search-and-retrieve-data-xml-simply-using-vbnet-and-linq
This might be helpful.