p_SetXMLElementCData (QTP, TestComplete, VBScript)

Categories: Source codeXML Data

Parent page: Service Functions – MSXMLDOM (QTP, TestComplete, VBScript)

Description

Remove all existing child CData nodes. Create a new CData node.

Implementation

Private Function p_SetXMLElementCData(ByRef objXMLElement, ByVal sValue)
 Dim objXMLDoc, objCDataNode
 Dim objColl, Iter
 'Remove all
 Set objColl = objXMLElement.ChildNodes
 Count = objColl.length-1
 Iter = 0
 Do While Iter <= Count
 If objColl.Item(Iter).NodeName = "#cdata-section" 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 objCDataNode = objXMLDoc.CreateCDATASection(sValue)
 objXMLElement.AppendChild(objCDataNode)
 p_SetXMLElementCData = True
End Function

  • Leave a Reply

    * Required
    ** Your Email is never shared

Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported
This work by the author is licensed under a Creative Commons Attribution-NonCommercial-NoDerivs 3.0 Unported.