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
'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
Comments