Reading XML

  • Thread starter Thread starter SS
  • Start date Start date
S

SS

Is there any way by which i can read each node(with
attribute and values) of an xml file as a string? Is there
a way to get this using XmlTextReader.
 
SS,

Do you mean something as this?

\\\\
Dim xmlString As String = "<department>" & _
"<employee name=""ABC"" age=""31"" sex=""male""/>" & _
"<employee name=""CDE"" age=""40"" sex=""male""/></department>"
Dim sr As New System.IO.StringReader(xmlString)
Dim doc As New Xml.XmlDocument
doc.Load(sr)
'or just in this case doc.LoadXML(xmlString)
Dim reader As New Xml.XmlNodeReader(doc)
While reader.Read()
Select Case reader.NodeType
Case Xml.XmlNodeType.Element
If reader.Name = "employee" Then
MessageBox.Show(reader.GetAttribute("name"))
End If
End Select
End While
///

I hope this helps a little bit?

Cor
 
Back
Top