Print Page | Close Window

Donate a user defined function to this topic

Printed From: One Stop Testing
Category: Testing Tools @ OneStopTesting
Forum Name: QuickTest Pro @ OneStopTesting
Forum Discription: QuickTest Pro is a fresh approach to automated software and application testing that addresses testing needs of both business analysts and Quality Assurance professionals.
URL: http://forum.onestoptesting.com/forum_posts.asp?TID=924
Printed Date: 25Dec2024 at 3:14pm


Topic: Donate a user defined function to this topic
Posted By: adela
Subject: Donate a user defined function to this topic
Date Posted: 25Apr2007 at 4:19am
I found similar topic for SilkTest tool and I though it is a good iead to do it for QTP too.

It will be very nice to see the invaluable findings at one place.
May I urge other experts on this forum to contibute user define function
and the problem you faced and the tips to overcome.

To start with I have a function as below.

Get Root Element attribute's value from XML file


Function GetRootElementAttributeValueFromXML(sFileNameWithPath,sAttribute)
' Why we need to ADD 2 because each attribute followed by (=) and (")
iLenOfValue=len(sAttribute) + 2
Set doc = XMLUtil.CreateXML()
doc.LoadFile sFileNameWithPath
Set root = doc.GetRootElement()
If instr(1,root,sAttribute) <= 0 then
Reporter.ReportEvent micFail,sAttribute,"Not Found in XML file."
exitrun(0)
else
sStartPos=instr(1,root,sAttribute) + iLenOfValue
sEndPos=instr(sStartPos,root,"""")
GetRootElementAttributeValueFromXML=mid(root,sStartPos,sEndPos - sStartPos)
end if
End Function

msgbox(GetRootElementAttributeValueFromXML("c:\temp\request.xml","MerchantId"))




Print Page | Close Window