// (2) You clear the oXmlNode.Attributes from the previous call ( saved in (1) ) // (1) You save a reference to oXmlNode.AttributesSo, if you need oXmlAttributeCollection afterwards
' If we have a content > If Not oXmlAttributeCollection Is Nothing Then > oXmlAttributeCollection.RemoveAll() > End Ifwith
' If we have a content > If Not oXmlAttributeCollection Is Nothing Then > oXmlAttributeCollection = Nothing > End Ifor
' If we have a content > oXmlAttributeCollection = Nothingps: For better performance, I would at the beginning of the function
Dim attr as String = UCase(tcAttribute)And in the loop use attr instead of UCase(tcAttribute)
> ' Get a XML node attribute > ' expC1 Node > ' expC2 Attribute > Public Function GetXMLNodeAttributeValue(ByVal tcNode As String, ByVal tcAttribute As String) As Boolean > Dim llFound As Boolean = False > Dim loAttribute As XmlAttribute = Nothing > > ' Reset the values > cMessage = "" > cNodeAttribute = "" > // (2) You clear the oXmlNode.Attributes from the previous call ( saved in (1) ) > ' If we have a content > If Not oXmlAttributeCollection Is Nothing Then > oXmlAttributeCollection.RemoveAll() > End If > > ' Select the node > If oXmlNameSpaceManager Is Nothing Then > oXmlNode = oXmlDocument.SelectSingleNode(tcNode) > Else > oXmlNode = oXmlDocument.SelectSingleNode(tcNode, oXmlNameSpaceManager) > End If > > ' If the node does not exist > If oXmlNode Is Nothing Then > cMessage = oApp.StrTran(cNodeDoesNotExist, "##Node##", tcNode) > Return False > End If > // (1) You save a reference to oXmlNode.Attributes > ' Assign the new attributes to this object > oXmlAttributeCollection = oXmlNode.Attributes > > ' Scan the attribute collection > For Each loAttribute In oXmlNode.Attributes > > ' If this is the one > If UCase(loAttribute.Name) = UCase(tcAttribute) Then > cNodeAttribute = loAttribute.Value > llFound = True > Exit For > End If > > Next > > ' If we did not find it > If Not llFound Then > cMessage = oApp.StrTran(cAttributeDoesNotExist, "##Attribute##", tcAttribute) > Return False > End If > > Return True > End Function >>