<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Kastang &#187; Armory</title>
	<atom:link href="http://kastang.com/blog/tag/armory/feed/" rel="self" type="application/rss+xml" />
	<link>http://kastang.com</link>
	<description>Ramblings of a Geek</description>
	<lastBuildDate>Sat, 11 Jun 2011 00:30:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.3</generator>
		<item>
		<title>Parsing the WoW Armory – Part 2.1</title>
		<link>http://kastang.com/blog/2010/01/parsing-the-wow-armory-%e2%80%93-part-2-1/</link>
		<comments>http://kastang.com/blog/2010/01/parsing-the-wow-armory-%e2%80%93-part-2-1/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 02:16:06 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[WoW]]></category>
		<category><![CDATA[Armory]]></category>
		<category><![CDATA[Parsing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[World of Warcraft]]></category>

		<guid isPermaLink="false">http://kastang.com/?p=266</guid>
		<description><![CDATA[I forgot to post this information in Part 2 of Parsing the WoW Armory. When parsing the guild-info.xml file, some fields are represented by  numerical values. Below is conversion table from XML numerical representations to actual values. genderId: 0 - Male 1 - Female raceId: 1 - Human 2 - Orc 3 - Dwarf 4 [...]]]></description>
			<content:encoded><![CDATA[<p>I forgot to post this information in Part 2 of Parsing the WoW Armory. When parsing the guild-info.xml file, some fields are represented by  numerical values. Below is conversion table from XML numerical representations to actual values.</p>
<p><strong>genderId:</strong><br />
0 - Male<br />
1 - Female</p>
<p><strong>raceId:</strong><br />
1 - Human<br />
2 -  Orc<br />
3 - Dwarf<br />
4 - Night Elf<br />
5 - Undead<br />
6 - Tauren<br />
7 - Gnome<br />
8 - Troll<br />
10 - Blood Elf<br />
11 - Draenei</p>
<p><strong>classId:</strong><br />
1 - Warrior<br />
2 - Paladin<br />
3 - Hunter<br />
4 - Rogue<br />
5 - Priest<br />
6 - Death Knight<br />
7 - Shaman<br />
8 - Mage<br />
9 - Warlock<br />
11 - Druid</p>
<p>For easy converting from numerical to actual values I would recommend using a PHP array(). Below is an example of the Sorted Guild list from Part 2 with the addition of the class of each character included.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #000000; font-weight: bold;">function</span> sortedList<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$classArray</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Warrior&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">2</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Paladin&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">3</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Hunter&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">4</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Rogue&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">5</span> <span style="color: #339933;">=&gt;</span> 
          <span style="color: #0000ff;">&quot;Priest&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">6</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Death Knight&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">7</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Shaman&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">8</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Mage&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">9</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Warlock&quot;</span><span style="color: #339933;">,</span> <span style="color: #cc66cc;">11</span> <span style="color: #339933;">=&gt;</span> <span style="color: #0000ff;">&quot;Druid&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> getName<span style="color: #009900;">&#40;</span><span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; - &quot;</span><span style="color: #339933;">.</span>getLevel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; - &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$classArray</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#40;</span>int<span style="color: #009900;">&#41;</span>getClassId<span style="color: #009900;">&#40;</span><span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$array</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://kastang.com/blog/2010/01/parsing-the-wow-armory-%e2%80%93-part-2-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing the WoW Armory – Part 2</title>
		<link>http://kastang.com/blog/2010/01/parsing-the-wow-armory-%e2%80%93-part-2/</link>
		<comments>http://kastang.com/blog/2010/01/parsing-the-wow-armory-%e2%80%93-part-2/#comments</comments>
		<pubDate>Wed, 13 Jan 2010 00:50:04 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[WoW]]></category>
		<category><![CDATA[Armory]]></category>
		<category><![CDATA[Parsing]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[World of Warcraft]]></category>

		<guid isPermaLink="false">http://kastang.com/?p=256</guid>
		<description><![CDATA[I chose to expand on Part 1 by providing a function file that provides access to all available character related information from the guild-info.xml file from the WoW Armory. The guild-info.xml file provides the following information for the entire guild: Achievement Points, Class ID, Gender ID, Level, Character Name, Race ID, Guild Rank, URL to [...]]]></description>
			<content:encoded><![CDATA[<p>I chose to expand on Part 1 by providing a function file that provides access to all available character related information from the guild-info.xml file from the WoW Armory. The guild-info.xml file provides the following information for the entire guild: Achievement Points, Class ID, Gender ID, Level, Character Name, Race ID, Guild Rank, URL to Character Page. </p>
<p>Some neat things can be calculated by using the available resources. I provided three examples in the code below: Average achievement points, average level, and a sorted list of all characters in the guild (also provided in Part 1).</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
&nbsp;
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user_agent&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.2) Gecko/20121223 Ubuntu/9.25 (jaunty) Firefox/3.8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
&nbsp;
<span style="color: #666666; font-style: italic;">//Average guild achievement score. </span>
<span style="color: #000000; font-weight: bold;">function</span> achAverage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$counter</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$total</span> <span style="color: #339933;">+=</span> getAchPoints<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$counter</span><span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$total</span><span style="color: #339933;">/</span><span style="color: #000088;">$counter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Sorted Guild Characters Names/Levels in ABC Order. </span>
<span style="color: #000000; font-weight: bold;">function</span> sortedList<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> getName<span style="color: #009900;">&#40;</span><span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; - &quot;</span><span style="color: #339933;">.</span>getLevel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br&gt;&quot;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">return</span> <span style="color: #000088;">$array</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Returns the average level of the entire guild. </span>
<span style="color: #000000; font-weight: bold;">function</span> avgLevel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #000088;">$counter</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$total</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #b1b100;">foreach</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #000088;">$total</span> <span style="color: #339933;">+=</span> getLevel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$p</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000088;">$counter</span><span style="color: #339933;">++;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #009900;">&#40;</span><span style="color: #000088;">$total</span><span style="color: #339933;">/</span><span style="color: #000088;">$counter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/**
 * Other functions that can be used to pull information
 * from the XML sheet. Use these functions to expand
 * and create other functions. 
 **/</span>
<span style="color: #000000; font-weight: bold;">function</span> getAchPoints<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'achPoints'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> getClassId<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'classId'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> getGenderId<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'genderId'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> getLevel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'level'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> getName<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> getRaceId<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'raceId'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> getRank<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'rank'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
<span style="color: #000000; font-weight: bold;">function</span> getURL<span style="color: #009900;">&#40;</span><span style="color: #000088;">$x</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #b1b100;">return</span> <span style="color: #000088;">$x</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'url'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>New functions can be created by using the get functions at the bottom of the file. Using the get functions and sample functions, it should be easy enough to expand on what I have. </p>
<p>The below code is an example of how to use the function code from above.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?php
<span style="color: #666666; font-style: italic;">//Functions file. </span>
<span style="color: #b1b100;">include</span> <span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'guild.php'</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Set Server/Guild Here. </span>
<span style="color: #000088;">$server</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Eitrigg&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$guild</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;We+Know&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$url</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'http://www.wowarmory.com/guild-info.xml?r='</span><span style="color: #339933;">.</span><span style="color: #000088;">$server</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;gn='</span><span style="color: #339933;">.</span><span style="color: #000088;">$guild</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guildInfo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guild</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">members</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">character</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//-------ABOVE THIS LINE IS REQUIRED----------</span>
&nbsp;
&nbsp;
<span style="color: #666666; font-style: italic;">//Below are some possible ways to use the functions. </span>
&nbsp;
<span style="color: #009933; font-style: italic;">/** Prints Without Array Numbers **/</span>
<span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$i</span><span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">,</span> <span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> sortedList<span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #339933;">;</span> <span style="color: #000088;">$i</span><span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009933; font-style: italic;">/** Alternative Implementation, Prints with Array Numbers
print_r(sortedList($xml));
**/</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Displays the average number of guild achievements. </span>
<span style="color: #b1b100;">echo</span> achAverage<span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//Displays the average level of the guild. </span>
<span style="color: #b1b100;">echo</span> avgLevel<span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://kastang.com/blog/2010/01/parsing-the-wow-armory-%e2%80%93-part-2/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Parsing the WoW Armory &#8211; Part 1</title>
		<link>http://kastang.com/blog/2010/01/parsing-the-wow-armory-part-1/</link>
		<comments>http://kastang.com/blog/2010/01/parsing-the-wow-armory-part-1/#comments</comments>
		<pubDate>Sun, 10 Jan 2010 22:17:35 +0000</pubDate>
		<dc:creator>Josh</dc:creator>
				<category><![CDATA[Computer]]></category>
		<category><![CDATA[WoW]]></category>
		<category><![CDATA[Armory]]></category>
		<category><![CDATA[Parsing PHP]]></category>

		<guid isPermaLink="false">http://kastang.com/?p=234</guid>
		<description><![CDATA[Today I pulled a list of every character in We Know from the WoW Armory in 5 lines of code. &#60; ?PHP ini_set&#40;&#34;user_agent&#34;, &#34;Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.2) Gecko/20121223 Ubuntu/9.25 (jaunty) Firefox/3.8&#34;&#41;; $url='http://www.wowarmory.com/guild-info.xml?r=Eitrigg&#38;gn=We+Know'; $xml = simplexml_load_file&#40;$url&#41;; &#160; foreach&#40;$xml-&#62;guildInfo-&#62;guild-&#62;members-&#62;character as $char&#41; echo $char&#91;'name'&#93;.&#34; - &#34;.$char&#91;'level'&#93;.&#34;&#60;br /&#62;&#34;; ?&#62; I never realized how easy is was [...]]]></description>
			<content:encoded><![CDATA[<p>Today I pulled a list of every character in We Know from the WoW Armory in 5 lines of code.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?PHP
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user_agent&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.2) Gecko/20121223 Ubuntu/9.25 (jaunty) Firefox/3.8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$url</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'http://www.wowarmory.com/guild-info.xml?r=Eitrigg&amp;gn=We+Know'</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guildInfo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guild</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">members</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">character</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span>
        <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$char</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; - &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$char</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'level'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>I never realized how easy is was to pull information from the WoW Armory until now. My method has its obvious flaws, such as the output is in no obvious order. I modified my original script to sort the list in ABC order and added a $server and $guild variable to allow for easy modification. Below is a more refined version, in under 15 lines of code the pulled list is sorted in ABC order and displayed.</p>

<div class="wp_syntax"><div class="code"><pre class="php" style="font-family:monospace;"><span style="color: #339933;">&lt;</span> ?PHP
<span style="color: #990000;">ini_set</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user_agent&quot;</span><span style="color: #339933;">,</span> <span style="color: #0000ff;">&quot;Mozilla/5.0 (X11; U; Linux i686; pl-PL; rv:1.9.0.2) Gecko/20121223 Ubuntu/9.25 (jaunty) Firefox/3.8&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$server</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;Eitrigg&quot;</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$guild</span> <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;We+Know&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$url</span><span style="color: #339933;">=</span><span style="color: #0000ff;">'http://www.wowarmory.com/guild-info.xml?r='</span><span style="color: #339933;">.</span><span style="color: #000088;">$server</span><span style="color: #339933;">.</span><span style="color: #0000ff;">'&amp;gn='</span><span style="color: #339933;">.</span><span style="color: #000088;">$guild</span><span style="color: #339933;">;</span>
<span style="color: #000088;">$xml</span> <span style="color: #339933;">=</span> <span style="color: #990000;">simplexml_load_file</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$url</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$array</span> <span style="color: #339933;">=</span> <span style="color: #990000;">array</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #b1b100;">foreach</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$xml</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guildInfo</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">guild</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">members</span><span style="color: #339933;">-&gt;</span><span style="color: #004000;">character</span> <span style="color: #b1b100;">as</span> <span style="color: #000088;">$char</span><span style="color: #009900;">&#41;</span>
        <span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> <span style="color: #000088;">$char</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'name'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot; - &quot;</span><span style="color: #339933;">.</span><span style="color: #000088;">$char</span><span style="color: #009900;">&#91;</span><span style="color: #0000ff;">'level'</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">.</span><span style="color: #0000ff;">&quot;&lt;br /&gt;&quot;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #990000;">sort</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000088;">$i</span> <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
<span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">!=</span> <span style="color: #009900; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">echo</span> <span style="color: #000088;">$array</span><span style="color: #009900;">&#91;</span><span style="color: #000088;">$i</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
    <span style="color: #000088;">$i</span><span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">?&gt;</span></pre></div></div>

<p>This script is just a quick and dirty way to accomplish the simple task of pulling names from the WoW Armory. I would recommend against using this in a production environment without some sort of cache/database option implemented.</p>
]]></content:encoded>
			<wfw:commentRss>http://kastang.com/blog/2010/01/parsing-the-wow-armory-part-1/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

