Help in parsing xml from url or file

Hi,

I saw your XMLParser.suite in http://www.redstonesoftware.com/phpBB2/viewtopic.php?t=209&highlight=xml. In that suite, xml data is kept within the script and that is being parsed.

I want to parse the xml data from the url like, http://www.w3schools/xml/simple.xml or to load the xml file from my SUT (OS Windows 2003 server)

Can you provide script for implementing this within the same example suite which is provided. Thanks kindly

Able to do with url but not able to read the .xml file from my SUT

If you have version 4.1 of Eggplant, you can use the new built-in support for XML trees. Here’s how you could read that URL and parse it:

put url "http://www.w3schools.com/xml/simple.xml" as tree into breakfast

This creates a SenseTalk tree structure containing the XML data. Then you can access items within the data in various ways:

put item 1 of breakfast
put the text of node "food/name" of breakfast
put all nodes "food/name" of breakfast

See Chapter 16 of the SenseTalk Reference manual (Working with Trees and XML) for full details.

To access XML from a file instead of a URL, replace the url expression in the top example with a file expression instead. That will work fine for a local file on the Eggplant machine. For a file on the SUT, the best (simplest) option is usually to mount the SUT’s file system on the Mac through file sharing (SMB on Windows). Then you can treat the file just the same as if it were a local file.

If that’s not possible, you’ll have to do something a bit more challenging, like script Eggplant to open the file in a text editor on the SUT, copy the data to the clipboard, and use the remoteClipboard() function to access the text. There’s usually a way to get what you need, but sometimes it’s not obvious.