Solved

Webrowser Control - Qs - get tag properties etc

Posted on 2004-04-14
3
284 Views
Last Modified: 2010-04-17
q1 - I need to get the value of a table cell [I think it has no specific id or name]

q2 - I'm trying to list off the properties of the td tags but don't know any other properties to check [other than tagname and id], is there a WWW reference to all the objects and their respect properties for Webrowser1.Document...???

For Each iItem In WebBrowser1.Document.All.tags("td")
 Debug.Print iItem.tagname, iItem.Id
Next

- I figure there is a constant heading "Amount" in one cell, so if I get the ?text/value? from the next cell, I will be golden.



0
Comment
Question by:williamsF1
3 Comments
 
LVL 1

Accepted Solution

by:
someman4oneman earned 60 total points
ID: 10829208
Welcome to the land of DOM traversal.....
Here is some code that I ran in VB script which should give you an idea of
what you need to do.
'*******************************************************
'Get your list
Dim NodeList
Set NodeList = Document.getElementsByTagName("td")

'I am iterating with count instead of your collection
'because I use the count  to get the next node once I have got the amount node
For iItem = 0 To NodeList.Length - 1

            'The text in a td is a node so I get the
                'the child node of the TD and see if it equals "Amount"
            If NodeList(iItem).childNodes(0).nodeValue = "Amount" Then
                        'If it does equal amount then get the text of the next td node
                  MsgBox(NodeList(iItem + 1).childNodes(0).nodeValue)
            End If
Next
'*******************************************************

My test doc is

<html>
      <body>
            <table>
                  <tr>
                        <td>invalid</td>
                        <td>Amount</td>
                        <td>1000</td>
                  </tr>
                  <tr>
                        <td>Amount</td>
                        <td>1000</td>
                                <td>invalid</td>
                  </tr>
            </table>
      </body>
</html>

It may seem convoluted but  think the idea is to have a standard mechanism across all languages
for accessing XML.(thats Standards for ya) If I was to do the same thing in Java my code would look very similar.

0
 

Author Comment

by:williamsF1
ID: 10836150
I think I got this to work, but one last thing, how would I get the href value from

<TD align=right width="50%">
<A class=Blue href="https://192.168.0.10/preparer_1.asp">
Clickhere
</A>
</TD>
0
 

Assisted Solution

by:fungord
fungord earned 20 total points
ID: 10853399

For Each iItem In WebBrowser1.Document.Links
 if iItem.innertext = "Clickhere" then
    Debug.Print iItem.tagname, iItem.innertext, iItem.href
    Exitfor
 endif
Next

To find out move info on the object, while debugging you could 'add a watch' to iItem.

0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This article will show, step by step, how to integrate R code into a R Sweave document
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
With the power of JIRA, there's an unlimited number of ways you can customize it, use it and benefit from it. With that in mind, there's bound to be things that I wasn't able to cover in this course. With this summary we'll look at some places to go…

685 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question