p_SetXMLElementText (QTP, TestComplete, VBScript)
Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript)
Description
Remove all existing child text nodes. Create a new text node.
Implementation
Private Function p_SetXMLElementText(ByRef objXMLElement, ByVal sValue) Dim objXMLDoc, objTextNode 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 = "#text" 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 objTextNode = objXMLDoc.CreateTextNode(sValue) objXMLElement.AppendChild(objTextNode) p_SetXMLElementText = True End Function