I'm having issues with extracting data from the below html code, for use in a Windows Phone 8.0 Silverlight app using htmlagilitypack.
What I want to do is have the div 'game white-c' as the starting point for my node selection.
I was trying to use
foreach (var div in htmlDocumentLive.DocumentNode.SelectNodes("//div[contains(@class, 'game white-c')]"))
But this doesn't work.
Additionally, sometimes only Game3 may be available so I would need a conditional statement such as position() = 3
. Other times, maybe Game1 and Game4 will be available. So I would need it to firstly check for all games. If any are unavailable i.e. contain no data, the code would then attempt to go through each game and try to load it before moving onto the next.
<section class="gamelist">
<div class="grid">
<div class="vc gamessection">
<div class="col-1-4">
<h2 class="white-c">Get free games</h2>
</div>
<div class="col-3-4">
<!-- GAME -->
<div class="game white-c">
<div class="boxshot">
<img class="boximg" alt="Game1" src="https://images.com" title="Game1">
</div>
</div>
<!-- END GAME -->
<!-- GAME -->
<div class="game white-c">
<div class="boxshot">
<img class="boximg" alt="Game2" src="https://images.com" title="Game2">
</div>
</div>
<!-- END GAME -->
<!-- GAME -->
<div class="game white-c">
<div class="boxshot">
<img class="boximg" alt="Game3" src="https://images.com" title="Game3">
</div>
</div>
<!-- END GAME -->
<!-- GAME -->
<div class="game white-c">
<div class="boxshot">
<img class="boximg" alt="Game4" src="https://images.com" title="Game4">
</div>
</div>
<!-- END GAME -->
<!-- GAME -->
<div class="game white-c">
<div class="boxshot">
<img class="boximg" alt="Game5" src="https://images.com" title="Game5">
</div>
</div>
<!-- END GAME -->
</div>
</div>
</div>
</section>
Thanks.