preload

p_GetXMLElementTextByIndex (QTP, TestComplete, VBScript)

Posted by Albert Gareev on Jul 17, 2008 | Categories: Source codeXML Data

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

Description

Get inner text from a child node specified by index.

Implementation

Private Function p_GetXMLElementTextByIndex(ByRef objXMLElement, ByVal intIndex)
  Dim objColl, Iter, IndexIter

  Set objColl = objXMLElement.ChildNodes
  IndexIter = -1
  For Iter=0 To objColl.length-1
    If objColl.Item(Iter).NodeName = "#text" Then
      IndexIter = IndexIter + 1
      If IndexIter = intIndex Then
        p_GetXMLElementTextByIndex = objColl.Item(Iter).NodeValue
        Exit Function
      End If
    End If
  Next
  p_GetXMLElementTextByIndex = ""
  
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.