preload

GetChildElementByAttr (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Aug 27, 2008 | Categories: Source codeXML Data

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

Description

Returns child XML node via XPath query.

Implementation

Public Function GetChildElementByAttr(ByRef objXMLParent, ByVal sTagName, ByVal sAttrName)
 Dim objNode

  sTagName = Trim(sTagName)
  sAttrName = Trim(sAttrName)

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

 Set objNode = objXMLParent.SelectSingleNode("./"&sTagName&"[@name='" & sAttrName &"']")
 If isNull(objNode) or (objNode is Nothing) Then
    Set GetChildElementByAttr = Nothing
  Else
    Set GetChildElementByAttr = objNode
 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.