Use Following function to reading data from the XML
U have to pass the XML file name and Node name as argument for this function
Hope this will help you.
With Best Regards,
Nil111
U have to pass the XML file name and Node name as argument for this function
Hope this will help you.
With Best Regards,
Nil111
Code:
Function Fn_GetXMLNodeValue(XMLDataFile, sNodeName)
Dim objXMLDoc
Dim objChildNodes
Dim objSelectNode
Dim intNodeLength
Dim intNodeCount
Dim intChildNodeCount
Dim strNodeSting
set objXMLDoc=CreateObject("Microsoft.XMLDOM") ' Create XMLDOM object
objXMLDoc.async="false"
objXMLDoc.load(XMLDataFile) ' Loading QTP Environment XML
If (objXMLDoc.parseError.errorCode <> 0) Then
Fn_GetXMLNodeValue = False
Else
intNodeLength = objXMLDoc.getElementsByTagName("Variable").length
For intNodeCount = 0 to (intNodeLength - 1)
Set objChildNodes = objXMLDoc.documentElement.childNodes.item(intNodeCount).childNodes
strNodeSting = ""
For intChildNodeCount = 0 to (objChildNodes.length - 1)
strNodeSting = strNodeSting & objChildNodes(intChildNodeCount).text
Next
If Instr(strNodeSting, sNodeName) Then
Set objSelectNode = objXMLDoc.SelectSingleNode("/Environment/Variable[" & intNodeCount &"]/Value")
Fn_GetXMLNodeValue = objSelectNode.Text
Exit For
End If
Next
Set objSelectNode = nothing
Set objChildNodes = nothing
Set objXMLDoc = nothing
If Fn_GetXMLNodeValue = "" Then
Fn_GetXMLNodeValue = False
End If
End if
End Function
