Jump to content
Sign in to follow this  
tobject

ImportXML & XPath

Recommended Posts

tobject

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

=importXML("URL";"query")

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
PsaltyDS

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
tobject

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

Now in AutoIt I get 0 nodes back

Any idea why?

$xmlDoc=ObjCreate("Microsoft.XMLDOM");
    if IsObj($xmlDoc) Then
       MsgBox(0,"sdsdsd","Success");
   endif;

    $xmlDoc.async=false;
    $xmlDoc.load("Profile616.htm");
    $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);

MsgBox(0,"sdsdsd",$xmlNodeList.Length);


    For $xmlNode in $xmlNodeList
        MsgBox(0,"sdsdsd",$xmlNode.Text);
    Next

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  

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.