?
Solved

WebBrowser - How to select HTMLElement as LIKE *FooterText ?

Posted on 2009-04-16
5
Medium Priority
?
836 Views
Last Modified: 2012-05-06
Hi,
I need to select HTMLElement:
HtmlElement el = (HtmlElement)DOC.GetElementById("_ctl0__ctl0_rcList_rList__ctl2_lFooterText");
But part of this element differs by page - _ctl0__ctl0_rcList_rList__ctl2, _ctl0__ctl0_rcList_rList__ctl3.

I need to select from page an Element which ends with "_lFooterText".
0
Comment
Question by:exceter
  • 3
  • 2
5 Comments
 
LVL 3

Author Comment

by:exceter
ID: 24165089
I tried to make as follows:
string tmp = "_ctl0__ctl0_rcList_rList__ctl";
int i = cnt;
string linstr = tmp+i.ToString()+"_lFooterText";

but cant know what the cnt will be,
0
 
LVL 3

Author Comment

by:exceter
ID: 24165121
Better I did a simple counter in my program, which counts hits on page. It works now.
0
 
LVL 8

Expert Comment

by:rweil
ID: 24173554
How about using a foreach to step through all the elements, get the id and look for the trailing _|FooterText
0
 
LVL 3

Author Comment

by:exceter
ID: 24173656
I was thinking about that.
But could not search for trailing. Can you show a simple code for that ?
0
 
LVL 8

Accepted Solution

by:
rweil earned 900 total points
ID: 24173807
been a while since I worked in C#, not sure of the function names in C#

two  approaches should work for you

1) look for the characters _lFooterText with in the text.

2) determine the len of the string and then do of substring from the length-12 to the _lFooterText  

assume the id contains the name of the element.
 
1) various languages call this instr, indexof, strpos not sure what it is called in C#
if (strpos(id, "_lFooterText") > 0 ) then
     /* found a match */
end if
 
2) option 2
 ii = strlen(id)
 if (ii > 12) then
    if (strncmp(substring(id, ii -12), "_lFooterText",12) == 0 ) then
        /* found a match */
    end if
 end if
   

Open in new window

0

Featured Post

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

Entity Framework is a powerful tool to help you interact with the DataBase but still doesn't help much when we have a Stored Procedure that returns more than one resultset. The solution takes some of out-of-the-box thinking; read on!
High user turnover can cause old/redundant user data to consume valuable space. UserResourceCleanup was developed to address this by automatically deleting user folders when the user account is deleted.
Are you ready to place your question in front of subject-matter experts for more timely responses? With the release of Priority Question, Premium Members, Team Accounts and Qualified Experts can now identify the emergent level of their issue, signal…
As many of you are aware about Scanpst.exe utility which is owned by Microsoft itself to repair inaccessible or damaged PST files, but the question is do you really think Scanpst.exe is capable to repair all sorts of PST related corruption issues?
Suggested Courses
Course of the Month14 days, 1 hour left to enroll

807 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