Micro Focus QTP (UFT) Forums
Expected End statement error - Printable Version

+- Micro Focus QTP (UFT) Forums (https://www.learnqtp.com/forums)
+-- Forum: Micro Focus UFT (earlier known as QTP) (https://www.learnqtp.com/forums/Forum-Micro-Focus-UFT-earlier-known-as-QTP)
+--- Forum: UFT / QTP Beginners (https://www.learnqtp.com/forums/Forum-UFT-QTP-Beginners)
+--- Thread: Expected End statement error (/Thread-Expected-End-statement-error)



Expected End statement error - Lavanya N - 07-21-2015

Hi All
I am using the below code to retrieve data from xml file. I need to retrieve xml value for many nodes hence thought of passing the node path for xml from datasheet. But when I execute the code i'm getting "Expected End statement" error.

Please find the code below:

Code:
Datatable.ImportSheet "filepath", "sheetname", 1

Set xmlDoc = CreateObject("Microsoft.XMLDOM")
xmlDoc.Async = False

XMLDataFile = "xmlFilepath"
xmlDoc.Load (XMLDataFile)

Set nodes = xmlDoc.SelectNodes Datatable.Value ("XML_Node") 'Here I'm passing "/ListOfOrder/Order/Id/text()" value in datasheet
    
msgbox "total count of id tag is " & nodes.length

For i = 0 To (nodes.Length - 1)

Id = nodes(i).NodeValue

Msgbox  "The name of Author is " & Id

Next

I am getting "Expected End statement" error in line:
Code:
Set nodes = xmlDoc.SelectNodes Datatable.Value ("XML_Node")

Pls help in resolving this


RE: Expected End statement error - kbhargava505 - 07-22-2015

Hi,

Replace the line

Code:
Set nodes = xmlDoc.SelectNodes Datatable.Value ("XML_Node")

with

Code:
Set nodes = xmlDoc.SelectNodes( Datatable.Value ("XML_Node",Global))

and replace the line

Code:
Id = nodes(i).NodeValue

with

Code:
Id = nodes(i).Text



RE: Expected End statement error - Lavanya N - 07-27-2015

Hey Bhargava...... ur code worked out.....!!!
Thanks a Lottt Smile