p_SetXMLElementComment (QTP, TestComplete, VBScript)
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript)
Description
Remove all existing comments. Create a new node.
Implementation
Private Function p_SetXMLElementComment(ByRef objXMLElement, ByVal sValue) Dim objXMLDoc, objCommentNode Dim objColl, Iter, Count 'Remove all Set objColl = objXMLElement.ChildNodes Count = objColl.length-1 Iter = 0 Do While Iter <= Count If objColl.Item(Iter).NodeName = "#comment" Then Call objXMLElement.RemoveChild(objColl.Item(Iter)) Count = Count - 1 Else Iter = Iter + 1 End If Loop 'Create / Add new Set objXMLDoc = objXMLElement.OwnerDocument Set objCommentNode = objXMLDoc.CreateComment(sValue) objXMLElement.AppendChild(objCommentNode) p_SetXMLElementComment = True End Function