HTMLAgilitypack getting <P> and <STRONG> text

Posted by StealthRT on Stack Overflow See other posts from Stack Overflow or by StealthRT
Published on 2012-11-07T04:55:05Z Indexed on 2012/11/07 5:00 UTC
Read the original article Hit count: 477

Hey all i am looking for a way to get this HTML code:

<DIV class=channel_row><SPAN class=channel>
<DIV class=logo><IMG src='/images/channel_logos/WGNAMER.png'></DIV>
<P><STRONG>2</STRONG><BR>WGNAMER </P></SPAN>

using the HtmlAgilityPack.

I have been trying this:

With channel
  info!Logo = .SelectSingleNode(".//img").Attributes("src").Value
  info!Channel = .SelectSingleNode(".//span[@class='channel']").ChildNodes(1).ChildNodes(0).InnerText
  info!Station = .SelectSingleNode(".//span[@class='channel']").ChildNodes(1).ChildNodes(2).InnerText
End With

I can get the Logo but it comes up with a blank string for the Channel and for the Station it says

Index was out of range. Must be non-negative and less than the size of the collection.

I've tried all types of combinations:

info!Station = .SelectSingleNode(".//span[@class='channel']").ChildNodes(1).ChildNodes(1).InnerText
info!Station = .SelectSingleNode(".//span[@class='channel']").ChildNodes(1).ChildNodes(3).InnerText
info!Station = .SelectSingleNode(".//span[@class='channel']").ChildNodes(0).ChildNodes(1).InnerText
info!Station = .SelectSingleNode(".//span[@class='channel']").ChildNodes(0).ChildNodes(2).InnerText
info!Station = .SelectSingleNode(".//span[@class='channel']").ChildNodes(0).ChildNodes(3).InnerText

What do i need to do in order to correct this?

© Stack Overflow or respective owner

Related posts about html

Related posts about vb.net