Question How to parse <div class> and <a href> innertext to listview control orderly?

firwer

New member
Joined
Aug 23, 2015
Messages
1
Programming Experience
Beginner
How to parse <div class> and <a href> innertext to listview control orderly?

Hi there everyone,
Lets say if I have a bunch of div class and a href on my website which I want to parse them to my listview control, how do I do so?

<div class="cookie1">5</div>

<div class="cookie2">11</div>
<div class="cookie3">10</div>

<div class="cake1">3</div>
<div class="cake2">21</div>
<div class="cake3">26</div>

<div class="_a">
<div class="_b">
<a href="/c1/123456/abc1">Thomas</a>
</div>
</div>
<div class="_a">
<div class="_b">
<a href="/c1/654321/abc2">Alvin</a>
</div>
</div>
<div class="_a">
<div class="_b">
<a href="/c1/274722/abc3">James</a>
</div>
</div>How do I express it to my listview control like this?
jVkwJ5d.png

I'm currently using this code to parse the name from the website to the listview control

VB.NET:
Dim[/COLOR][COLOR=#000000] elements [/COLOR][COLOR=#000088]As[/COLOR][COLOR=#000000] HtmlElementCollection [/COLOR][COLOR=#666600]=[/COLOR][COLOR=#000000] WebBrowser1[/COLOR][COLOR=#666600].[/COLOR][COLOR=#000000]document[/COLOR][COLOR=#666600].[/COLOR][COLOR=#000000]All

   [/COLOR][COLOR=#000088]For [/COLOR][COLOR=#000088]Each[/COLOR][COLOR=#000000] webpageelement [/COLOR][COLOR=#000088]As[/COLOR][COLOR=#000000] HtmlElement [/COLOR][COLOR=#000088]In[/COLOR][COLOR=#000000] elements
    [/COLOR][COLOR=#000088]If[/COLOR][COLOR=#000000] webpageelement[/COLOR][COLOR=#666600].[/COLOR][COLOR=#000000]GetAttribute[/COLOR][COLOR=#666600]([/COLOR][COLOR=#008800]"href"[/COLOR][COLOR=#666600])[/COLOR][COLOR=#666600]=[/COLOR][COLOR=#008800]"/c1/"  [/COLOR][COLOR=#000088]Then[/COLOR][COLOR=#000000]
           ListView1[/COLOR][COLOR=#666600].[/COLOR][COLOR=#000000]Items[/COLOR][COLOR=#666600].[/COLOR][COLOR=#000000]Add[/COLOR][COLOR=#666600]([/COLOR][COLOR=#000000]webpageelement[/COLOR][COLOR=#666600].[/COLOR][COLOR=#000000]InnerText[/COLOR][COLOR=#666600])[/COLOR][COLOR=#000000]
    [/COLOR][COLOR=#000088]End [/COLOR][COLOR=#000088]If[/COLOR][COLOR=#000000]
   [/COLOR][COLOR=#000088]Next
[/COLOR][COLOR=#000088]

But how do I parse the number of cookies and cakes to the another two more separate rows?

Is it possible to parse the two items column by column first instead of row by row?
I hope you all get what Im trying to say, thanks!
 
Last edited:
Top Bottom