Click here to Skip to main content
15,891,136 members
Please Sign up or sign in to vote.
3.00/5 (2 votes)
See more:
Hi Guys

I was just wondering if anybody can help me with a problem i have been having. Basically what i am trying to do is grab an element off a WebPage by it's class name and make Vb automatically look up to see if there is a number greater than what is contained within the element. I have the html code below.

0


So in my case i am wanting to say something like

if classname = "mam_limit_num") and contains an integer >0
then do something



Any suggestions here guys.

Thank You In Advance.
Posted
Comments
Sergey Alexandrovich Kryukov 28-Jun-12 13:28pm    
Does not seem to make sense -- just yet. Can you explain everything properly? Is it ASP.NET, or what? What is the "class"? CSS class, .NET class? Why class name?
--SA
fatcake 28-Jun-12 13:46pm    
Ok
I was just wondering if anybody can help me with a problem i have been having. (It is to do with Html on an Webpage and Visual Basic) Basically what i am trying to do is grab an element off a WebPage by it's (class name, html element name seen below in html code) and make Vb automatically look up to see if there is a number greater than what is contained within the element. I have the html code below.


"<div class="mam_limit_num">4</div>"


So in my case i am wanting to say something like

if classname = "mam_limit_num") and contains an integer >0
then do something

Thank you in advance.
Sergey Alexandrovich Kryukov 28-Jun-12 14:01pm    
By what code? Is it off-line? Or by JavaScript on the same page, on the fly? Or what? And why?
--SA
fatcake 28-Jun-12 14:08pm    
it is offline, it is a the html of it. Any suggestions or.
fatcake 28-Jun-12 16:03pm    
bump

1 solution

The question is very, very unclear. Please see my comment to the question.

But perhaps even preliminary notes will help you to solve the problem.

If this is ASP.NET and you are talking about CSS class, you can use JavaScript with jQuery with either the selector ".class" or using CSS methods. Please see:
http://api.jquery.com/class-selector/[^],
http://api.jquery.com/category/selectors/[^],
http://api.jquery.com/category/css/[^],
http://api.jquery.com/hasClass/[^].

If you need to learn jQuery, this is a good start:
http://docs.jquery.com/Tutorials:How_jQuery_Works[^].

If you are talking about .NET classes: every object of all type (both reference and value types) can use the method GetType, because this is the method of System.Object which is a base class for all types:
http://msdn.microsoft.com/en-us/library/system.object.gettype.aspx[^].

And you don't need to compare type names (actually, you should never do it), you should compare instances of System.Type themselves, using the "==" operator. To compare two references by type taking into account the inheritance, you need to use the Is operator:
http://msdn.microsoft.com/en-us/library/kb136x1y.aspx[^].

You should really understand .NET type system very well, as this is the most important thing. But first thing you should understand about comparison of object by their type to provide different functionality: this is the huge fundamental abuse of OOP, something that totally defeats OOP approach. Don't do it. Instead, learn how OOP works.

So, if you are not quite satisfied with this answer, you should explain properly what do you want to achieve. Start with explanation of your ultimate goals. I'm quite sure the real solution will not be based on type comparison.

[EDIT]

Thank you for clarification, but they are still not 100% clear, and you should have explained it in first place. There is no pre-installed XML parser in .NET. If this is an HTML code well-formed as XML, you are lucky, can use any available XML parser. If this is not the case, you will need some HTML parser which can deal with that. You can use this one:
http://www.majestic12.co.uk/projects/html_parser.php[^].

—SA
 
Share this answer
 
v3
Comments
fatcake 28-Jun-12 14:01pm    
um, ok i am wanting to do this in Visual Basic 2010 Express. Do you know what a class is in html first?
Sergey Alexandrovich Kryukov 29-Jun-12 3:33am    
Added update, after [EDIT].
--SA

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900