Display an XmlNode contents in a DataGrid?
This code snippet shows how you can show an XmlNode contents in a DataGrid.
There are several occasions specially when accessing Web Services; data coming from the Web Service is in an XmlNode, not in DataSet and you want to display the contents of the XmlNode in a DataGrid.
The way to do is, simply convert XmlNode into a DataSet object and bind the DataSet to the DataGrid.
Dim funcAreasNode As XmlNode = GetNode()
If Not node Is Nothing And node.InnerXml.Length > 0 Then
Dim reader as XmlTextReader = New XmlTextReader(node.OuterXml, XmlNodeType.Element, Nothing)
Dim ds as DataSet = New DataSet
ds.ReadXml(reader)
End If
DataGrid1.DataSource = ds
DataGrid1.DataBind()