Parsing the WoW Armory without XML – Part 2
This post is a continuation of my original post about parsing the WoW Armory with no XML feeds available. In my original post, I showed how to pull basic character information, such as professions and talents, from each member in a specified guild. This post will expand on more specific character information such as HP, MP, and Stats.
The getCharacterInformation($charName) function in my previous post can be expanded to include additional information available on the WoW Armory. (Please view my original post for the sample code). For the most part, the code below can be directly copied into the existing method. As in my previous post, I assume you have the knowledge to make minor changes to the method (such as modifying the return array).
Exact Health and Mana:
$health = $xpath->query('//li[@class="health"]/span[@class="value"]'); $mana = $xpath->query('//li[@id="summary-power"]/span[@class="value"]'); echo $health->item(0)->nodeValue."<br />"; echo $mana->item(0)->nodeValue."<br />";
Exact Talents:
This will return the exact talent in the form of xx/xx/xx for both talents.
$exactBuilds = $xpath->query('//span[@class="name-build"]/span[@class="build"]'); echo $exactBuilds->item(0)->nodeValue."<br />"; echo $exactBuilds->item(1)->nodeValue;
Stats and Resistances:
A stat listed in the comment above the code needs to be added to the $stat variable.
/** * Valid $stat values: * strength, agility, stamina, intellect, * spirit, mastery, meleedamage, meleedps, * meleeattackpower, meleespeed, meleehaste, * meleehit, meleecrit, meleecrip, expertise, * rangeddamage, rangeddps, rangedattackpower, * rangedspeed, rangedhaste, rangedhit, rangedcrit, * spellpower, spellhaste, spellhit, spellcrit, * spellpenetration, manaregen, combatregen, armor, * dodge, parry, block, resilience, arcaneres, fireres, * frostres, natureres, shadowres, */ $stat = "ADD_STAT_FROM_ABOVE_HERE"; $statName = $xpath->query('//li[@data-id="'.$stat.'"]/span[@class="name"]'); $statValue = $xpath->query('//li[@data-id="'.$stat.'"]/span[@class="value"]'); echo $statName->item(0)->nodeValue."<br />"; echo $statValue->item(0)->nodeValue."<br />";
Battleground Rating and Kills
$rating = $xpath->query('//li[@class="rating"]/span[@class="value"]'); $kills = $xpath->query('//li[@class="kills"]/span[@class="value"]'); echo $rating->item(0)->nodeValue."<br />"; echo $kills->item(0)->nodeValue."<br />";
My next post will cover looking into more interesting character information such as Achievements, Reputation, or Statistics.

ScifiToday
January 8th, 2011 - 09:35
*applaud*
Thank you
I would appreciate your adding known recipes for consideration in future updates.