padinski

Description list tags <dl> IE funciton

4 posts in this topic

Hi,

I have a list of address id's at work that need to be looked up in an external site. Once the site finds the address by the id, it returns a list of attributes against that id.

Here is a snippet of the source code, what I want to extract and copy to my excel spreadsheet is the "Service Class" within the <dd> tags. This is the 5th set of <dd> tags within all the HTML on the full page:

<div id="spinner"></div>
            <div id="search-result-outer" style="width: 100%">
                    <h2>Selected address</h2>
<fieldset class="section">
    <dl id="displayAddress">
        <dt>Address</dt>
        <dd>7 Fake Street, Faketown</dd>
    </dl>
    <dl id='locationId'>
        <dt>Location ID</dt>
        <dd>LOC00001234567</dd>
    </dl>
    <dl id='primary-access-technology'>
        <dt>Access technology</dt>
            <dd>Fibre</dd>
    </dl>
<dl>
    <dt>Service class</dt>
    <dd>2 - Serviceable by fibre. Drop in place, no NTD.    </dd>
</dl>

If I use:

$oDD = _IETagNameGetCollection($oIE, "dd", 4) ; Find the 5th DD tag
MsgBox($MB_SYSTEMMODAL, "dd", $oDD)

it returns "0" in the msg box, instead of "2 - Serviceable by fibre. Drop in place, no NTD"

The following gives me an object error.

$oDD = _IETagNameGetCollection($oIE, "dd", 4) ; Find the 5th DD tag
MsgBox($MB_SYSTEMMODAL, "dd", $oDD.innertext)

Am i approaching this the right way? Any advice assistance would be greatly appreciated. Thank you.

Share this post


Link to post
Share on other sites



Well, you can use my signature example...getting ie obj from xpath.

Yours would be like this:

$aMatches = BGe_IEGetDOMObjByXPathWithAttributes($oIE,"//fieldset[@class='section']/dl/dt[.='Service class']")
$oParent = $aMatches[0].ParentNode

$aMatches = BGe_IEGetDOMObjByXPathWithAttributes($oParent,"/dd")
$text = $aMatches[0].innertext

ConsoleWrite($text & @CRLF)

 


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

Share this post


Link to post
Share on other sites

Thanks jdelaney, excuse my ignorance as I have not used any custom UDF's before. i just copied your script from the link in you signature and named it IEGetDOMObjByXPathWithAttributes.au3 and put it in my personal UDF folder. In my script I then added #include <IEGetDOMObjByXPathWithAttributes.au3> (hope that's correct process...)

When i use those lines of code you provided I get the following error:

$oParent = $aMatches[0].ParentNode
$oParent = $aMatches^ERROR

Error:Subscript used on non-accessible variable.

Sorry if that's a stupid question.

Share this post


Link to post
Share on other sites

That means that no dom objects were found matching the pattern.  Was the page fully loaded when you called the function?

You can check that the return is an array (isarray), if not, then nothing was found.


IEbyXPATH-Grab IE DOM objects by XPATH IEscriptRecord-Makings of an IE script recorder ExcelFromXML-Create Excel docs without excel installed GetAllWindowControls-Output all control data on a given window.

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