Derek,
I doubt if anybody will have code for this specific question of you.
However this is code that shows easily how to use the node reader maybe you
can expiriment with the most inner part in the loop.
\\\\
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,
Cor
"Derek Hart" <de********@yahoo.comschreef in bericht
news:OI**************@TK2MSFTNGP04.phx.gbl...
Does anybody have code for this?
"GhostInAK" <gh*******@gmail.comwrote in message
news:c7**************************@news.microsoft.c om...
>Hello Derek,
You could use a recursive function that operated on XmlNode objects (see
XmlNode in MSDN docs or Object Browser). Or you could use an XmlReader
and process each node as it was streamed in. I really have no experience
using XmlNavigator or XmlReader.. so I can only speak about the XmlNode
method.
I'll outline the process in pseudo code.. you can give it a shot from
there.
Load the XML into an XmlDocument
Pass the root node to the recursive function
The recursive function will take an XmlNode as input.
Function guts:
Process node (read all attributes; read node text)
For each childNode in inputNode.ChildNodes
pass childnode to function
End For
End Function
Enjoy,
-Boo
>>For testing purposes, I need some code that will loop through all
attributes and elements in an XML file, and replace the data with the
element or attribute name? Does anybody have code that will do this,
looping generically through every node? VB.Net code would be
appreciated so I can see how it is done.
Derek