So I had a code project that took the name of a piece of equipment in World
of Warcraft - pulled the XML from WoWhead and pulled the database item
number from the XML file. It worked for a long while and the code simply sat
around not being used. I went back to pull the project out for inclusion in
something new and it no longer works.
I wasn't terribly comfortable with XML to begin with so I'm not sure what
has changed - but here is the code the worked for so long:
function item_num_from_xml($url)
{
$xml = new SimpleXMLElement(rawurlencode($url), NULL, TRUE);
$item_num = $xml->items->item[id];
return $item_num;
}
$xml_link = "http://www.wowhead.com/?search=".str_replace(" ", "+",
$item)."&xml";
$item_num = item_num_from_xml($xml_link);
$itemlink = "http://www.wowhead.com/?item=".$item_num;
This is the error message I now get:
*Warning*: SimpleXMLElement::__construct()
[simplexmlelement.--construct<http://www.theredshirts.com/test/simplexmlelement.--construct>]:
http%3A%2F%2Fwww.wowhead.com%2F%3Fsearch%3DAngelista%27s%2BSash%26xml:84:
parser error : Entity 'nbsp' not defined in *
/home/thered/public_html/test/config.php* on line *28
**Warning*: SimpleXMLElement::__construct()
[simplexmlelement.--construct<http://www.theredshirts.com/test/simplexmlelement.--construct>]:
pan> <span
class="moneycopper">64</span></div></li><li><div>Disenchantable in *
/home/thered/public_html/test/config.php* on line *28*
and various other beauties including:
*Fatal error*: Uncaught exception 'Exception' with message 'String could not
be parsed as XML' in /home/thered/public_html/test/config.php:28 Stack
trace: #0 /home/thered/public_html/test/config.php(28):
SimpleXMLElement->__construct('http%3A%2F%2Fww...', 0, true) #1
/home/thered/public_html/test/config.php(105): item_num_from_xml() #2
/home/thered/public_html/test/display.php(86): display_drops('
http://www.wowh...') #3 /home/thered/public_html/test/index.php(2):
include('/home/thered/pu...') #4 {main} thrown in *
/home/thered/public_html/test/config.php* on line *28
First person to point out what stupid mistake I'm making can mock me for a
long time.
*