Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 146
  • Last Modified:

recurse through the entire web page to find an element

How to recurse through the entire web page (dom structure) which contains frames, iframes and look for a particular element (say a button) ?
0
zazenz
Asked:
zazenz
  • 6
  • 5
1 Solution
 
Mark_FreeSoftwareCommented:

is it always the same button?

if so, then you can use InStr function
0
 
zazenzAuthor Commented:
that wouldn't work. in the first place how do i get hold of the source code for the iframe ?
0
 
Mark_FreeSoftwareCommented:

what is your starting point?

are you developing a plugin for ie/ firefox
are you reading a html file on your pc,
do you need to read html files on a server
do you have a webbrowser control in your app?
0
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 
zazenzAuthor Commented:
thanks for responding. its a html page on my PC.
0
 
zazenzAuthor Commented:
i'll elaborate this a bit, A recursive algorithm that parses the entire dom tree and shows if an element is present or not. any ideas on this would be greatly appreciated.
0
 
Mark_FreeSoftwareCommented:

do you want to compare it to a default page?
(same structure but then with different text or somthing?)

because you can parse it all, but i don't exactly understand what you are trying to do so it is very difficult to answer in the good direction
0
 
zazenzAuthor Commented:
Mark_FreeSoftware,
what I am trying accomplish here is look for a particular element (button) in the web page and click it. This page that I am talking about has many frames and is kind of complex with a huge dom structure. So my Vb program has to parse through each frame and look for if the element exists or not. and if the particular element exists then it has to take an action. I am working on writing the algorithm and any ideas regarding this is a great welcome.
0
 
Mark_FreeSoftwareCommented:

you could do somthing like this:


Dim tmp As String, tmp2 As String, i As Long
tmp = "<your<html> here>"
While tmp <> ""
    i = InStr(tmp, "<")
    If i > 0 Then
        tmp = Right$(tmp, Len(tmp) - i + 1)
        i = InStr(tmp, ">")
        If i = 0 Then MsgBox "Error in html!": Exit Sub
        tmp2 = Left$(tmp, i)
        'process whatever you want
        'the first element is now in tmp2
        tmp = Right$(tmp, Len(tmp) - i)
    Else
        tmp = ""
    End If
Wend


maybey you can even keep some sort of stack with the elements you encountered
0
 
zazenzAuthor Commented:
thanks a lot, i'll give it a try and shall let you know about it.
0
 
zazenzAuthor Commented:
Mark_FreeSoftware,
           I figured it out. I used some of your ideas. and thanks for all the help.
0
 
Mark_FreeSoftwareCommented:


well, i'm glad you have figured somthing out!


and thanx for the points,
mark
0

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

  • 6
  • 5
Tackle projects and never again get stuck behind a technical roadblock.
Join Now