preload

GetChildElementValueByAttr (QTP, TestComplete, VBScript)

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

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

Description

Returns text value of a child XML node found via XPath query.

Implementation

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

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

 If objXMLParent is Nothing Then
  GetChildElementValueByAttr = ""
  Exit Function
 End If

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