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.
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
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.
Re: Help with HtmlAgilityPack only grab last line
Try modifying the SelectNodes expression to
Code:
.//div//span[contains(@id, 'line_')]
- kgc
Re: Help with HtmlAgilityPack only grab last line
Quote:
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)
Re: Help with HtmlAgilityPack only grab last line
Quote:
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.
Quote:
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