I'm using the followg code to add the attribute overwrite='true" to a select list of XML tags in an XML document. The document is loaded from a file and just the tags with names matching what's in the ArrayList are updated to contain the new attribute. However, after it saves back to the XML file, I find that only the last one in the list was updated and all the ones prior to the last one in the loop are skipped. Why is it losing the updates before the last one? How can I get it to add the attribute to all the tags in the list? Thanks.
--------------------------------------------------------------------------------
Dim Tg As OverwritableTag
Dim XD As XmlDocument
Dim XNL As XmlNodeList
Dim XN As XmlNode
Dim XA As XmlAttribute
If alOVR.Count 0 Then
XD = New XmlDocument()
XD.Load(mXmlPath)
XA = XD.CreateAttribute("overwrite")
XA.Value = "true"
For Each Tg In alOVR
XNL = XD.GetElementsByTagName("ml:" & [Enum].GetName(GetType(OverwritableTag), Tg))
For Each XN In XNL
XN.Attributes.Append(XA)
Next
Next
XD.Save(mXmlPath)
XD = Nothing
End If