All
I am using the code below in order to read an XML file in the format:
<root>
<selection-attr attr="p70">
<value code="Mr">Mr</value>
<value code="Mrs">Mrs</value>
<value code="Ms">Ms</value>
<value code="Miss">Miss</value>
<caption>Title:</caption>
</selection-attr>
</root>
What I am trying to do is identify the element name of the text node ie.
<caption>. On an element node I can use reader.Name but I have been unable
to identify how to read the value for a text node. I would appreciate any
assistance.
Thanks
' ---------
' Code Snippet
'
Dim sr As New System.IO.StreamReader("c:\xml.xml")
Dim sw As New System.IO.StreamWriter("c:\output.txt")
Dim attr As String
Dim doc As New Xml.XmlDocument
doc.Load(sr)
Dim reader As New Xml.XmlNodeReader(doc)
While reader.Read()
Select Case reader.NodeType
Case Xml.XmlNodeType.Element
If reader.Name = "text-attr" Or reader.Name = "selection-attr" Then
attr = reader.GetAttribute("attr")
End If
Case Xml.XmlNodeType.Text
sw.WriteLine(attr & ", " & reader.Name & ", " & reader.Value)
End Select
End While
sw.Close()