QTP-XML service functions (1) – ChildElementByName
Posted by Albert Gareev on 2009/07/14
Parent page: Service Functions – XML (QTP, VBScript)
Description
Returns XML child node (as XMLElement object reference) specified by an xml tag name. If there are multiple objects with the same tag, returns the first reference. If there are no objects with the tag specified returns “Nothing”.
Public Function ChildElementByName(ByRef objXMLParent, ByVal sTagName)
Dim objColl
If objXMLParent is Nothing Then
Set ChildElementByName = Nothing
Exit Function
End If
Set objColl = objXMLParent.ChildElementsByPath("./"&sTagName)
If objColl.Count >0 Then
Set ChildElementByName = objColl.Item(1)
Else
Set ChildElementByName = Nothing
End If
End Function
Service Functions – XML (QTP, VBScript) « Automation Beyond said
[...] Returns reference of XML Element [...]