For starters, thank you in advance!
I am able to extract a section of code from a web page that looks similar to the following block of code.
<div id="playerStats">
<div id="hp"><span class="title">HP:</span></div>
<div id="mp"><span class="title">MP:</span></div>
<div id="magicResist"><span class="title">Magic Resist</span></div>
<div id="physicalDefend"><span class="title">Physical Defence</span></div>
<div id="phyCriticalReduceRate"><span class="title">Strike Resist</span></div>
<div id="phyCriticalDamageReduce"><span class="title">Strike fortitude</span></div>
<div id="physicalRight"><span class="title">Main Hand Attack</span></div>
<div id="accuracyRight"><span class="title">Main Hand Accuracy</span></div>
<div id="criticalRight"><span class="title">Main Hand Critical</span></div>
<div id="physicalLeft"><span class="title">Off Hand Attack</span></div>
<div id="accuracyLeft"><span class="title">Off Hand Accuracy</span></div>
<div id="criticalLeft"><span class="title">Off Hand Critical</span></div>
<div id="attackSpeed"><span class="title">Attack Speed</span></div>
<div id="magicalBoost"><span class="title">Magic Boost</span></div>
<div id="magicalAccuracy"><span class="title">Magic Accuracy</span></div>
<div id="magicalCriticalRight"><span class="title">Crit Spell</span></div>
<div id="castingTimeRatio"><span class="title">Casting Speed</span></div>
<div id="block"><span class="title">Block</span></div>
<div id="dodge"><span class="title">Evasion</span></div>
</div>
from the following uri for this character statistics page of a video game. (And you should clearly see the table of stats in the middle of the page.) If you use your browser's function similar to Google Chrome's F-12 to view the html source code, you will notice there are values in between /span and /div similar to the following code:
<div id="playerStats">
<div id="hp"><span class="title">HP:</span>"12213"</div>
<div id="mp"><span class="title">MP:</span>"4000"</div>
<div id="magicResist"><span class="title">Magic Resist</span>"4618"</div>
<div id="physicalDefend"><span class="title">Physical Defence</span>"1725"</div>
<div id="phyCriticalReduceRate"><span class="title">Strike Resist</span>"1518"</div>
<div id="phyCriticalDamageReduce"><span class="title">Strike fortitude</span>"392"</div>
<div id="physicalRight"><span class="title">Main Hand Attack</span>"201"</div>
<div id="accuracyRight"><span class="title">Main Hand Accuracy</span>"201"</div>
<div id="criticalRight"><span class="title">Main Hand Critical</span>"201"</div>
<div id="physicalLeft"><span class="title">Off Hand Attack</span>"201"</div>
<div id="accuracyLeft"><span class="title">Off Hand Accuracy</span>"201"</div>
<div id="criticalLeft"><span class="title">Off Hand Critical</span>"201"</div>
<div id="attackSpeed"><span class="title">Attack Speed</span>"201"</div>
<div id="magicalBoost"><span class="title">Magic Boost</span>"201"</div>
<div id="magicalAccuracy"><span class="title">Magic Accuracy</span>"201"</div>
<div id="magicalCriticalRight"><span class="title">Crit Spell</span>"201"</div>
<div id="castingTimeRatio"><span class="title">Casting Speed</span>"201"</div>
<div id="block"><span class="title">Block</span>"201"</div>
<div id="dodge"><span class="title">Evasion</span>"201"</div>
</div>
And to go on, I am using the following code to retrieve the first block of html code described above.
HtmlDocument doc = new HtmlDocument();
doc.Load(MyTestFile);
foreach(var node in doc.DocumentNode.SelectNodes("//div[@id='playerStats']/div/span"))
{
Console.WriteLine(node.InnerText + " " + (node.NextSibling != null ? node.NextSibling.InnerText : null));
}
I have used the WebRequest, WebClient, WebBrowser and HtmlWeb-agilitypack classes to pull the html document down from the web. However, the most important part from which I wish to extract is not being pulled down in the document which is the values associated with Hp, mp, etc... The expected values are described in the second block of html code above.
How can I get my code to bring down this simple text in the document for me to parse as well?