I'm trying to parse complex html using HtmlAgilityPack
<tr>
<td width=0%>Artist:</td><td width=23% class='colour'><a href='/p/beatmaplist?q=Akiakane'>Akiakane</a></td>
<td width=0%>Circle Size:</td><td width=23% class='colour'><div class='starfield' style='width:140px'><div class='active' style='width:56px'></div></div></td>
<td width=0%>Approach Rate:</td><td class="colour"><div class='starfield' style='width:140px'><div class='active' style='width:126px'></div></div></td>
</tr>
<tr>
<td width=0%>Title:</td><td class="colour"><a href='/p/beatmaplist?q=FlashBack'>FlashBack</a></td>
<td width=0%>HP Drain:</td><td class="colour"><div class='starfield' style='width:140px'><div class='active' style='width:84px'></div></div></td>
<td width=0%><strong>Star Difficulty</strong>:</td><td width=23% class='colour'><div class='starfield' style='width:140px'><div class='active' style='width:72.9650211334px'></div></div> (5.21)</td>
</tr>
<tr>
<td width=0%>Creator:</td><td class="colour"><a href='/u/231111'>Kiiwa<a/></td>
<td width=0%>Accuracy:</td><td class="colour"><div class='starfield' style='width:140px'><div class='active' style='width:98px'></div></div></td>
<td width=0%>Length:</td><td class="colour">3:13 (2:49 drain)</td>
</tr>
<tr>
<td width=0%>Source:</td><td class="colour"><a href='/p/beatmaplist?q='></a></td>
<td width=0%>Genre:</td><td class="colour"><a href='/p/beatmaplist?g=4'>Rock</a> (<a href='/p/beatmaplist?la=3'>Japanese</a>)</td>
<td width=0%>BPM:</td><td class="colour">185</td>
</tr>
<tr>
<td width=0%>Tags:</td><td class="colour"><a href="/p/beatmaplist?q=j-pop">j-pop</a> <a href="/p/beatmaplist?q=beren">beren</a> <a href="/p/beatmaplist?q=collaboration">collaboration</a> <a href="/p/beatmaplist?q=collab">collab</a> <a href="/p/beatmaplist?q=boroboro">boroboro</a> <a href="/p/beatmaplist?q=na">na</a> <a href="/p/beatmaplist?q=ikizama">ikizama</a> <a href="/p/beatmaplist?q=niki">niki</a> <a href="/p/beatmaplist?q=niconicodouga">niconicodouga</a> <a href="/p/beatmaplist?q=toysfactory">toysfactory</a> </td>
<td width=0%>User Rating:</td><td class="colour">
<table width="100%" height="20px" style="color:#fff;">
<tr>
<td style="background-color:#BC2036;text-align:right;border:solid 1px #82000B;" width="3.37522441652">93</td>
<td style="background-color:#78AB23;text-align:left;border:solid 1px #718F0A;" width="96.6965888689">2,692</td>
</tr>
Each tr should be a object with the included td as properties. I. e.
public class SongInfo
{
public string CS { get; set; }
public string AR { get; set; }
public string HP { get; set; }
public string STAR { get; set; }
public string LENGTH { get; set; }
public string BPM { get; set; }
}
so, In this context, it should look like this:
CS should be "Circle Size: (starfield style % divided by active style %)"
AR should be "Approach Rate: (starfield style % divided by active style %)"
HP should be "HP Drain: (starfield style % divided by active style %)"
STAR should be "Star Difficulty: (starfield style % divided by active style %)"
LENGTH should be "Length: 3:13"
BPM should be "BPM: 185"
When I say (starfield style % divided by active style %), I'm referring to this code:
<div class='starfield' style='width:140px'><div class='active'style='width:56px'></div>
So in that situation, it should be 2.5 since 140/56 = 2.5
My first thought was something like this:
foreach (HtmlAgilityPack.HtmlNode node in doc.DocumentNode.SelectNodes("//tr"))
{
foreach (HtmlAgilityPack.HtmlNode node2 in node.SelectNodes("//td[@width]=0%"))
{
}
}
But honestly, I have no idea how to go with HtmlAgilityPack since I haven't really used it at all.
Is it possible to do what I'm asking?