Automation Beyond

Testing and Test Automation for Software Quality Assurance. Above Requirements. Beyond Expectations. Methodologies and concepts. Framework Design. Programming and Scripting. Created by Albert Gareev.

QTP-XML service functions (2) – ChildElementValueByName

Posted by Albert Gareev on 2009/07/15

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

Description

Returns scalar value of the XML child node specified by an xml tag name. If there are multiple objects with the same tag, returns value of the first reference. If there are no objects with the tag specified returns “” (empty string).

Public Function ChildElementValueByName(ByRef objXMLParent, ByVal sTagName)
	Dim objColl

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

	Set objColl = objXMLParent.ChildElementsByPath("./"&sTagName)
	If objColl.Count >0 Then
		ChildElementValueByName = objColl.Item(1).Value()
	Else
		ChildElementValueByName = ""
		Exit Function
	End If

End Function

One Response to “QTP-XML service functions (2) – ChildElementValueByName”

  1. [...] Returns text value of XML Element [...]

Leave a Reply

XHTML: You can use these tags: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <pre> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>