A
A
Alexey Smirnov2015-12-14 15:37:40
HTML
Alexey Smirnov, 2015-12-14 15:37:40

How can the IndexOf method (from the .NET framework) explain that inside the method's brackets, any text can be placed between some HTML tags?

Hello.
I am extracting data from the HTML code of some web page. And I'm doing this with Visual Basic and the .NET framework.
To get data from the HTML code, I use the IndexOf method, and when using it, inside the method brackets, there may be different HTML code, or this:

i = СТРОКА.IndexOf("<td><strong><a id="iraq" href="некоторая_ссылка">Ирак</a></strong></td>")

or like this:
i = СТРОКА.IndexOf("<td><strong>Сербия</strong></td>")

I need to move to a generic use of the IndexOf method so that this method can be used for both cases.
How can the IndexOf method explain that any text (or HTML code) can be placed between tags and ? I.e:<td><strong></strong></td>
i = СТРОКА.IndexOf("<td><strong> Здесь располагается любой текст или HTML-код </strong></td>")

Answer the question

In order to leave comments, you need to log in

1 answer(s)
I
Ivan Filatov, 2015-12-14
@ERAFY

1. do not use IndexOf for parsing pages
2. or drag data through regular expressions (not the easiest and most reliable way)
3. or take either HtmlAgilityPack ( https://htmlagilitypack.codeplex.com/) and you can pull out anything you want through Xpath.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question