parse($strYourXML); print_r($arrOutput); //print it out, or do whatever! */ class xml2Array { var $arrOutput = array(); var $resParser; var $strXmlData; function parse($strInputXML) { $this->resParser = xml_parser_create (); xml_set_object($this->resParser,$this); xml_set_element_handler($this->resParser, "tagOpen", "tagClosed"); xml_set_character_data_handler($this->resParser, "tagData"); $this->strXmlData = xml_parse($this->resParser,$strInputXML ); if(!$this->strXmlData) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->resParser)), xml_get_current_line_number($this->resParser))); } xml_parser_free($this->resParser); return $this->arrOutput; } function tagOpen($parser, $name, $attrs) { $tag=array("name"=>$name,"attrs"=>$attrs); array_push($this->arrOutput,$tag); } function tagData($parser, $tagData) { if(trim($tagData)) { if(isset($this->arrOutput[count($this->arrOutput)-1]['tagData'])) { $this->arrOutput[count($this->arrOutput)-1]['tagData'] .= $tagData; } else { $this->arrOutput[count($this->arrOutput)-1]['tagData'] = $tagData; } } } function tagClosed($parser, $name) { $this->arrOutput[count($this->arrOutput)-2]['children'][] = $this->arrOutput[count($this->arrOutput)-1]; array_pop($this->arrOutput); } } //$url="http://armory.wow-europe.com/character-sheet.xml?r=Terenas&n=Thumann"; function curl_string ($url,$user_agent){ $ch = curl_init(); curl_setopt ($ch, CURLOPT_URL, $url); curl_setopt ($ch, CURLOPT_USERAGENT, $user_agent); curl_setopt ($ch, CURLOPT_HEADER, 1); curl_setopt ($ch, CURLOPT_RETURNTRANSFER, 1); curl_setopt ($ch, CURLOPT_FOLLOWLOCATION, 1); curl_setopt ($ch, CURLOPT_TIMEOUT, 120); $result = curl_exec ($ch); curl_close($ch); return $result; } $url_page = "http://armory.wow-europe.com/character-sheet.xml?r=Terenas&n=Thumann"; $user_agent = "Mozilla/5.0 Firefox/2.0.0.1"; $xml = curl_string($url_page,$user_agent); /*$xml= ' <knownTitles> <title value="Senior Sergeant"/> </knownTitles> <characterBars> <health effective="7348"/> <secondBar casting="18" effective="5383" notCasting="115" type="m"/> </characterBars> <baseStats> <strength attack="59" base="69" block="-1" effective="69"/> <agility armor="942" attack="461" base="146" critHitPercent="10.24" effective="471"/> <stamina base="110" effective="361" health="3430" petBonus="108"/> <intellect base="72" critHitPercent="5.50" effective="152" mana="2000" petBonus="-1"/> <spirit base="85" effective="119" healthRegen="18" manaRegen="97"/> <armor base="4142" effective="4142" percent="28.18" petBonus="1450"/> </baseStats> <resistances> <arcane petBonus="0" value="0"/> <fire petBonus="4" value="10"/> <frost petBonus="0" value="0"/> <holy petBonus="0" value="0"/> <nature petBonus="4" value="10"/> <shadow petBonus="7" value="17"/> </resistances> <melee> <mainHandWeaponSkill rating="0" value="346"/> <offHandWeaponSkill rating="0" value="0"/> <mainHandDamage dps="173.5" max="635" min="510" percent="0" speed="3.30"/> <offHandDamage dps="40.3" max="81" min="80" percent="0" speed="2.00"/> <mainHandSpeed hastePercent="0.00" hasteRating="0" value="3.30"/> <offHandSpeed hastePercent="0.00" hasteRating="0" value="2.00"/> <power base="660" effective="1122" increasedDps="80.0"/> <hitRating increasedHitPercent="2.66" value="42"/> <critChance percent="12.53" plusPercent="2.45" rating="54"/> </melee> <ranged> <weaponSkill rating="0" value="350"/> <damage dps="216.4" max="680" min="600" percent="0" speed="2.96"/> <speed hastePercent="0.00" hasteRating="0" value="2.96"/> <power base="736" effective="1284" increasedDps="91.0" petAttack="282.48" petSpell="165.25"/> <hitRating increasedHitPercent="2.66" value="42"/> <critChance percent="17.69" plusPercent="2.45" rating="54"/> </ranged> <spell> <bonusDamage> <arcane value="12"/> <fire value="12"/> <frost value="12"/> <holy value="12"/> <nature value="12"/> <shadow value="12"/> <petBonus attack="-1" damage="-1" fromType=""/> </bonusDamage> <bonusHealing value="12"/> <hitRating increasedHitPercent="0.00" value="0"/> <critChance rating="0"> <arcane percent="5.50"/> <fire percent="5.50"/> <frost percent="5.50"/> <holy percent="5.50"/> <nature percent="5.50"/> <shadow percent="5.50"/> </critChance> <penetration value="0"/> <manaRegen casting="18.00" notCasting="115.00"/> </spell> <defenses> <armor base="4142" effective="4142" percent="28.18" petBonus="1450"/> <defense decreasePercent="0.00" increasePercent="0.00" plusDefense="0" rating="0" value="346.00"/> <dodge increasePercent="0.00" percent="13.23" rating="0"/> <parry increasePercent="0.00" percent="4.84" rating="0"/> <block increasePercent="0.00" percent="0.00" rating="0"/> <resilience damagePercent="0.00" hitPercent="0.00" value="0.00"/> </defenses> <items> <item durability="85" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_helmet_73" id="21366" maxDurability="85" permanentenchant="0" randomPropertiesId="0" seed="2014690852" slot="0"/> <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_jewelry_necklace_20" id="31727" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="1732623184" slot="1"/> <item durability="85" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_shoulder_10" id="16937" maxDurability="85" permanentenchant="2606" randomPropertiesId="0" seed="0" slot="2"/> <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_shirt_12" id="18231" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="0" slot="3"/> <item durability="100" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_chest_chain_08" id="31782" maxDurability="100" permanentenchant="2376" randomPropertiesId="0" seed="1813260027" slot="4"/> <item durability="35" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_belt_23" id="31472" maxDurability="35" permanentenchant="0" randomPropertiesId="0" seed="171745334" slot="5"/> <item durability="75" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_pants_06" id="25821" maxDurability="75" permanentenchant="0" randomPropertiesId="0" seed="1671757938" slot="6"/> <item durability="70" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_boots_chain_13" id="16849" maxDurability="70" permanentenchant="1887" randomPropertiesId="0" seed="0" slot="7"/> <item durability="50" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_bracer_17" id="16935" maxDurability="50" permanentenchant="1593" randomPropertiesId="0" seed="0" slot="8"/> <item durability="50" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_gauntlets_10" id="16940" maxDurability="50" permanentenchant="2564" randomPropertiesId="0" seed="0" slot="9"/> <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_jewelry_ring_10" id="25054" maxDurability="0" permanentenchant="0" randomPropertiesId="-40" seed="878051357" slot="10"/> <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_jewelry_ring_40" id="21204" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="942680985" slot="11"/> <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_datacrystal06" id="28041" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="1396922351" slot="12"/> <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_misc_stonetablet_11" id="25937" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="245060712" slot="13"/> <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_misc_cape_20" id="25540" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="1864723832" slot="14"/> <item durability="100" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_spear_08" id="29329" maxDurability="100" permanentenchant="2646" randomPropertiesId="0" seed="1629587506" slot="15"/> <item durability="90" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_weapon_crossbow_09" id="19361" maxDurability="90" permanentenchant="664" randomPropertiesId="0" seed="0" slot="17"/> <item durability="0" gem0Id="0" gem1Id="0" gem2Id="0" icon="inv_shirt_guildtabard_01" id="5976" maxDurability="0" permanentenchant="0" randomPropertiesId="0" seed="0" slot="18"/> </items> </characterTab> <skillTab> <skillCategory key="professions" name="Professions"> <skill key="alchemy" max="375" name="Alchemy" value="366"/> <skill key="enchanting" max="375" name="Enchanting" value="322"/> </skillCategory> <skillCategory key="secondaryskills" name="Secondary Skills"> <skill key="cooking" max="300" name="Cooking" value="296"/> <skill key="firstaid" max="375" name="First Aid" value="375"/> <skill key="fishing" max="225" name="Fishing" value="195"/> <skill key="riding" max="225" name="Riding" value="225"/> </skillCategory> <skillCategory key="weaponskills" name="Weapon Skills"> <skill key="axes" max="350" name="Axes" value="327"/> <skill key="bows" max="350" name="Bows" value="300"/> <skill key="crossbows" max="350" name="Crossbows" value="350"/> <skill key="daggers" max="350" name="Daggers" value="325"/> <skill key="defense" max="350" name="Defense" value="346"/> <skill key="guns" max="350" name="Guns" value="290"/> <skill key="polearms" max="350" name="Polearms" value="346"/> <skill key="staves" max="350" name="Staves" value="115"/> <skill key="swords" max="350" name="Swords" value="300"/> <skill key="thrown" max="350" name="Thrown" value="1"/> <skill key="two-handedaxes" max="350" name="Two-Handed Axes" value="262"/> <skill key="two-handedswords" max="350" name="Two-Handed Swords" value="299"/> <skill key="unarmed" max="350" name="Unarmed" value="256"/> </skillCategory> <skillCategory key="classskills" name="Class Skills"> <skill key="beastmastery" max="0" name="Beast Mastery" value="350"/> <skill key="marksmanship" max="0" name="Marksmanship" value="350"/> <skill key="survival" max="0" name="Survival" value="350"/> </skillCategory> <skillCategory key="armorproficiencies" name="Armor Proficiencies"> <skill key="cloth" max="0" name="Cloth" value="1"/> <skill key="leather" max="0" name="Leather" value="1"/> <skill key="mail" max="0" name="Mail" value="1"/> </skillCategory> <skillCategory key="languages" name="Languages"> <skill key="language:orcish" max="300" name="Language: Orcish" value="300"/> <skill key="language:taurahe" max="300" name="Language: Taurahe" value="300"/> </skillCategory> </skillTab> <reputationTab> <factionCategory key="horde" name="Horde"> <faction key="darkspeartrolls" name="Darkspear Trolls" reputation="18296"/> <faction key="orgrimmar" name="Orgrimmar" reputation="17971"/> <faction key="silvermooncity" name="Silvermoon City" reputation="4725"/> <faction key="thunderbluff" name="Thunder Bluff" reputation="18529"/> <faction key="undercity" name="Undercity" reputation="12892"/> </factionCategory> <factionCategory key="hordeforces" name="Horde Forces"> <faction key="frostwolfclan" name="Frostwolf Clan" reputation="6770"/> <faction key="thedefilers" name="The Defilers" reputation="500"/> <faction key="warsongoutriders" name="Warsong Outriders" reputation="5043"/> </factionCategory> <factionCategory key="outland" name="Outland"> <faction key="cenarionexpedition" name="Cenarion Expedition" reputation="13979"/> <faction key="sporeggar" name="Sporeggar" reputation="3755"/> <faction key="theconsortium" name="The Consortium" reputation="7089"/> <faction key="thrallmar" name="Thrallmar" reputation="12234"/> </factionCategory> <factionCategory key="shattrathcity" name="Shattrath City"> <faction key="lowercity" name="Lower City" reputation="13513"/> <faction key="thealdor" name="The Aldor" reputation="6610"/> <faction key="thescryers" name="The Scryers" reputation="-7271"/> </factionCategory> <factionCategory key="steamwheedlecartel" name="Steamwheedle Cartel"> <faction key="bootybay" name="Booty Bay" reputation="7754"/> <faction key="everlook" name="Everlook" reputation="5852"/> <faction key="gadgetzan" name="Gadgetzan" reputation="6338"/> <faction key="ratchet" name="Ratchet" reputation="6690"/> </factionCategory> <factionCategory key="zother" name="Other"> <faction key="argentdawn" name="Argent Dawn" reputation="29647"/> <faction key="bloodsailbuccaneers" name="Bloodsail Buccaneers" reputation="-27525"/> <faction key="broodofnozdormu" name="Brood of Nozdormu" reputation="31452"/> <faction key="cenarioncircle" name="Cenarion Circle" reputation="24224"/> <faction key="darkmoonfaire" name="Darkmoon Faire" reputation="50"/> <faction key="hydraxianwaterlords" name="Hydraxian Waterlords" reputation="42999"/> <faction key="keepersoftime" name="Keepers of Time" reputation="8712"/> <faction key="ravenholdt" name="Ravenholdt" reputation="0"/> <faction key="thescaleofthesands" name="The Scale of the Sands" reputation="0"/> <faction key="thevioleteye" name="The Violet Eye" reputation="900"/> <faction key="thoriumbrotherhood" name="Thorium Brotherhood" reputation="9010"/> <faction key="timbermawhold" name="Timbermaw Hold" reputation="9045"/> <faction key="zandalartribe" name="Zandalar Tribe" reputation="42999"/> </factionCategory> </reputationTab> </characterInfo> </page>';*/ $objXML = new xml2Array(); $arrOutput = $objXML->parse($xml); print_r($arrOutput); //print it out, or do whatever! /*$name = $arrOutput[0]['children'][0]['children'][0]['attrs']['NAME']; $pvp_rank = $arrOutput[0]['children'][0]['children'][0]['attrs']['TITLE']; $guild = $arrOutput[0]['children'][0]['children'][0]['attrs']['GUILDNAME']; $level = $arrOutput[0]['children'][0]['children'][0]['attrs']['LEVEL']; $race = $arrOutput[0]['children'][0]['children'][0]['attrs']['RACE']; $class = $arrOutput[0]['children'][0]['children'][0]['attrs']['CLASS']; $realm = $arrOutput[0]['children'][0]['children'][0]['attrs']['REALM']; $faction = $arrOutput[0]['children'][0]['children'][0]['attrs']['FACTION']; $gender = $arrOutput[0]['children'][0]['children'][0]['attrs']['GENDER']; echo $pvp_rank.' '.$name.'<br>'; echo 'Level '.$level.' '.$race.' '.$class.'<br>'; echo 'Of '.$guild.', '.$realm.'<br>'; */ ?>