Jump to content
Sign in to follow this  

ImportXML & XPath

Recommended Posts

I was playing with Google spreadsheets _ImportXML function but they allow only 50 per sheet :idea:

is there a similar function for AutoIt? I checked Help - not much there


URL - the URL of the XML or HTML file

query - the XPath query to run on the data given at the URL. For example, "//a/@href" returns a list of the href attributes of all <a> tags in the document (i.e. all of the URLs the document links to). Each result from the XPath query is placed in its own row of the spreadsheet. For more information about XPath, please visit http://www.w3schools.com/xpath/

Example: =importXml("www.google.com"; "//a/@href"). This returns all of the href attributes (the link URLs) in all the <a> tags on www.google.com homepage

Share this post

Link to post
Share on other sites

AutoIt is not a spreadsheet. It can be used with the automation interfaces provided by some spreadsheets. For example, the COM interface to MS Excel. So if the version of Excel you had installed supported that equation format, then AutoIt could use Excel to perform it.

Native to AutoIt, you could pull down the XML with InetGet, and use the _XMLDOMWrapper UDF to perform XPath queries on it (the UDF uses MSXML).

Edited by PsaltyDS

Valuater's AutoIt 1-2-3, Class... Is now in Session!For those who want somebody to write the script for them: RentACoder"Any technology distinguishable from magic is insufficiently advanced." -- Geek's corollary to Clarke's law

Share this post

Link to post
Share on other sites

Ok I tested XPath in Google - it retrieves data just fine

Now in AutoIt I get 0 nodes back

Any idea why?

    if IsObj($xmlDoc) Then

    $xmlDoc.setProperty("SelectionLanguage", "XPath");
    $XPath="//td//td[(((count(preceding-sibling::*) + 1) = 1) and parent::*)]//tr[(((count(preceding-sibling::*) + 1) = 1) and parent::*)]//tr//td";

     $xmlNodeList = $xmlDoc.selectNodes($XPath);


    For $xmlNode in $xmlNodeList

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.

  • Create New...