QTP-XML service functions (4) – ChildAttributeValueByName
Posted by Albert Gareev on 2009/07/17
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, objAttrIf objXMLParent is Nothing ThenChildAttributeValueByName = “”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
Service Functions – XML (QTP, VBScript) « Automation Beyond said
[...] Returns text value of XML Attribute [...]