This is how I do things like this:
Dim xd As New XmlDocument()
xd.Load(SynLaunchXML)
If xd.DocumentElement IsNot Nothing Then
For Each Elem As XmlElement In xd.DocumentElement.ChildNodes
If Elem.Name = "App" Then
For Each E As XmlElement In Elem.ChildNodes
Select Case E.Name
Case "Name"
E.Value= sDisplayName
....
End Select
Next
Exit For
End If
Next
End If
Open the document. If it has a document element (
AdminTools
, in your example), cycle through its child nodes until you find the one named
App
. Then cycle through its child nodes and assign values based on the name of the element. After you have handled
App
, exit the outer loop.
This is a bit wordy, but has the advantage of bypassing all primary nodes not named
App
, including any comment nodes you may want to add. It also does not depend on
Name
and the other child nodes being in a particular order.
One other issue that might cause problems is that XML is
VERY picky about special characters. My rule is that if a node might have anything other than strictly alphanumeric characters, the data gets wrapped with CDATA. It is possible that the special characters could be causing problems, which is why I generally use
Value
rather than
InnerText
: with
Value
, the Framework's inner workings will determine if CDATA is needed or not and do the translation automatically.
Added: This article[
^] does a good job of explaining the difference between
Value
and
InnerText
, in case you are interested.