preload

QTP-XML service functions (4) – ChildAttributeValueByName

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


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

Description

Returns scalar value of the XML child attribute specified by a name. Attribute name duplication within the same node is not allowed by XML rules. If there is no attribute with the name specified then “” (empty string) is returned.

Public Function ChildAttributeValueByName(ByRef objXMLParent, ByVal sAttrName)
	Dim objColl, objAttr

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

	Set objColl = objXMLParent.Attributes()
	Set objAttr = objColl.ItemByName(sAttrName)

	If objAttr is Nothing Then
		ChildAttributeValueByName = ""
	Else
		ChildAttributeValueByName = objAttr.Value()
	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.