preload

QTP-XML service functions (6) – CreateChildElementByName

Posted by Albert Gareev on Nov 14, 2009 | Categories: Source codeXML Data


Parent page: Service Functions – XML (QTP, VBScript)

Description

Uses .AddChildElementByName method to create a child XML node, then returns reference to the newly created object. If Parent XML node is not defined returns “Nothing”.


Public Function CreateChildElementByName(ByRef objXMLParent, ByVal sTagName, ByVal sInnerText)
 Dim objColl

 If objXMLParent is Nothing Then
  Set CreateChildElementByName = Nothing
  Exit Function
 End If

 objXMLParent.AddChildElementByName sTagName, sInnerText

 Set objColl = objXMLParent.ChildElementsByPath(“./”&sTagName)
 If objColl.Count >0 Then
  Set CreateChildElementByName = objColl.Item(objColl.Count)
 Else
  Set CreateChildElementByName = Nothing
 End If
 
End Function


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