Courtney
02-20-2010, 03:15 AM
Hello,
I am a novice at php and xml and am having some difficulty parsing a simple xml document because of what I see as bad structure. I want to parse this link: http://www.wowhead.com/?item=10000&xml
I am using:
$doc = new DOMDocument();
$doc->load('http://www.wowhead.com/?item=10000&xml');
$arrFeeds = array();
foreach ($doc->getElementsByTagName('wowhead') as $node) {
$itemRSS = array (
'item id' => $node->getElementsByTagName('item id')->item(0)->nodeValue,
'name' => $node->getElementsByTagName('name')->item(0)->nodeValue,
'level' => $node->getElementsByTagName('level')->item(0)->nodeValue,
'quality' => $node->getElementsByTagName('quality')->item(0)->nodeValue,
'class id' => $node->getElementsByTagName('class id')->item(0)->nodeValue,
'subclass id' => $node->getElementsByTagName('subclass id')->item(0)->nodeValue,
'inventorySlot id' => $node->getElementsByTagName('inventorySlot id')->item(0)->nodeValue,
'htmlTooltip' => $node->getElementsByTagName('htmlTooltip')->item(0)->nodeValue,
'json' => $node->getElementsByTagName('json')->item(0)->nodeValue,
'jsonEquip' => $node->getElementsByTagName('jsonEquip')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
);
array_push($arrFeeds, $itemRSS);
}
print_r($arrFeeds);
My issue is the tags with the value in the tag like <item id="10000"> my output after parsing has the tag name but no value... [item id] =>
Can someone point me in the right direction?
I am a novice at php and xml and am having some difficulty parsing a simple xml document because of what I see as bad structure. I want to parse this link: http://www.wowhead.com/?item=10000&xml
I am using:
$doc = new DOMDocument();
$doc->load('http://www.wowhead.com/?item=10000&xml');
$arrFeeds = array();
foreach ($doc->getElementsByTagName('wowhead') as $node) {
$itemRSS = array (
'item id' => $node->getElementsByTagName('item id')->item(0)->nodeValue,
'name' => $node->getElementsByTagName('name')->item(0)->nodeValue,
'level' => $node->getElementsByTagName('level')->item(0)->nodeValue,
'quality' => $node->getElementsByTagName('quality')->item(0)->nodeValue,
'class id' => $node->getElementsByTagName('class id')->item(0)->nodeValue,
'subclass id' => $node->getElementsByTagName('subclass id')->item(0)->nodeValue,
'inventorySlot id' => $node->getElementsByTagName('inventorySlot id')->item(0)->nodeValue,
'htmlTooltip' => $node->getElementsByTagName('htmlTooltip')->item(0)->nodeValue,
'json' => $node->getElementsByTagName('json')->item(0)->nodeValue,
'jsonEquip' => $node->getElementsByTagName('jsonEquip')->item(0)->nodeValue,
'link' => $node->getElementsByTagName('link')->item(0)->nodeValue,
);
array_push($arrFeeds, $itemRSS);
}
print_r($arrFeeds);
My issue is the tags with the value in the tag like <item id="10000"> my output after parsing has the tag name but no value... [item id] =>
Can someone point me in the right direction?