|
-
Apr 28th, 2011, 06:46 PM
#1
Thread Starter
Frenzied Member
Getting HTML values into listbox
So i have some HTML like this
<li>
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>
</li>
<li>
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>
</li>
<li>
<div id="1"></div>
<div id="2"></div>
<div id="3"></div>
</li>
Right now i am doing a foreach loop on elements with the <div> tag, then checking if the id="1" if it does add the value to a listbox.
My problem is, i want to also get div id="2" value at the same time and add it to my listbox, since the Persons ID is in div 1 and the Name of the person is in Div2.
Any ideas on how to do this?
I was thinking i could do another for each loop, and just add the username behind the id i pull.
Question is, how do i add to a value or position in a listbox, after its been filled?
Last edited by joefox; Apr 28th, 2011 at 06:55 PM.
-
Apr 28th, 2011, 06:52 PM
#2
Re: Getting HTML values into listbox
where's the html coming from?
i'd use xdocument if possible
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 28th, 2011, 07:02 PM
#3
Thread Starter
Frenzied Member
Re: Getting HTML values into listbox
Its coming from some static html pages we have on our internal intranetsite
Last edited by joefox; Apr 28th, 2011 at 07:07 PM.
-
Apr 28th, 2011, 07:11 PM
#4
Thread Starter
Frenzied Member
Re: Getting HTML values into listbox
Ok so i have this below
For Counter As Integer = ListBox1.Items.Count - 1I To 0I Step -1I
ListBox1.Items.Insert(Counter, ListBox1.Items(Counter).ToString() & "/Joe")
Next Counter
I am able to loop through each of the items and update the value in the listbox but problem is it inserts a new item, not updating the current items its on.
I know im going about this wrong, but any other help would be great.
-
Apr 28th, 2011, 07:16 PM
#5
Re: Getting HTML values into listbox
vb Code:
For Counter As Integer = ListBox1.Items.Count - 1I To 0I Step -1I
ListBox1.Items(Counter) = ListBox1.Items(Counter).ToString() & "/Joe")
Next Counter
- Coding Examples:
- Features:
- Online Games:
- Compiled Games:
-
Apr 28th, 2011, 07:21 PM
#6
Thread Starter
Frenzied Member
Re: Getting HTML values into listbox
I dont think my method will work..
I am assuming that when i do my foreach on the html elments div 2, its going to match the elements found when i put my id's in the first time.
any other way to do this guys?
Any way i can look at the <li> items or whats inbetweent hat element and then parse whtas in it?
-
Apr 28th, 2011, 07:40 PM
#7
Thread Starter
Frenzied Member
Re: Getting HTML values into listbox
Edit, i see that for each <li>item i can get its inner html by doing MessageBox.Show(element.InnerHtml.ToString()) i think this might do the trick, since now i get all the elements within that html block.
Here is some exact html pulled from one my my intranet site pages. (Just changed some of the names )
<head><title>Employees A</title></head>
<body>
<li>
<div id="1">11</div>
<div id="2">Tom Jones</div>
<div id="3">Stage 3</div>
</li>
<li>
<div id="1">12</div>
<div id="2">Joe Thompson</div>
<div id="3">Stage 1</div>
</li>
<li>
<div id="1">13</div>
<div id="2">Billy Blanks</div>
<div id="3">Stage 9</div>
</li>
</body>
I would like to see something like this in my listbox
11 / Tom Jones
12 / Joe Thompson
13 / Billy Blanks
Last edited by joefox; Apr 28th, 2011 at 07:45 PM.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|