|
-
Feb 2nd, 2017, 06:30 PM
#1
Thread Starter
New Member
Help with HtmlAgilityPack only grab last line
Html
Code:
<div class="category-3223">
<span id="line_1">LINE 1 </span>
<span id="line_2">LINE 2</span>
</div>
My working code (but only grab line2)
Code:
Dim col As HtmlNodeCollection =
doc.DocumentNode.SelectNodes(".//span[contains(@id, 'line_')]")
How to grab all line?? (LINE 1 and LINE 2) because my code only grab LINE 2
Thanks.
-
Feb 2nd, 2017, 08:15 PM
#2
Re: Help with HtmlAgilityPack only grab last line
How do you know it's onlhy grabbing the one line? SelectNodes returns multiple notes... so what are you using to verify multiple nodes?
-tg
-
Feb 3rd, 2017, 12:01 AM
#3
Thread Starter
New Member
Re: Help with HtmlAgilityPack only grab last line
because I have tried that code and I dont know why
Code:
Dim col As HtmlNodeCollection =
doc.DocumentNode.SelectNodes(".//div[contains(@class, 'category-')]")
When I use code above it works by grabbing LINE 1LINE 2 without enter.
The point is how I can grab
LINE 1
LINE 2
Thanks.
-
Feb 3rd, 2017, 03:37 AM
#4
Re: Help with HtmlAgilityPack only grab last line
Try modifying the SelectNodes expression to
Code:
.//div//span[contains(@id, 'line_')]
- kgc
-
Feb 3rd, 2017, 04:56 AM
#5
Thread Starter
New Member
Re: Help with HtmlAgilityPack only grab last line
 Originally Posted by KGComputers
Try modifying the SelectNodes expression to
Code:
.//div//span[contains(@id, 'line_')]
- kgc
Thanks for reply and alternative solution, but it's still only grab last line (LINE 2)
-
Feb 3rd, 2017, 08:44 AM
#6
Re: Help with HtmlAgilityPack only grab last line
 Originally Posted by Oshix
because I have tried that code and I dont know why
Code:
Dim col As HtmlNodeCollection =
doc.DocumentNode.SelectNodes(".//div[contains(@class, 'category-')]")
When I use code above it works by grabbing LINE 1LINE 2 without enter.
The point is how I can grab
LINE 1
LINE 2
Thanks.
 Originally Posted by Oshix
Thanks for reply and alternative solution, but it's still only grab last line (LINE 2)
I'm going to try one more time... HOW are you figuring out that it is only grabbing one line? What is is you are doing that makes you go "It only has the one line, where's the other one?" ... you haven't shown us any new code or steps you're taking to validate the problem. Are you checking the count, the length, or what? What is it you then do with col to determine it has only one line in it?
-tg
Tags for this Thread
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
|