SimpleXML broke while I was sleeping.

------=_Part_140791_2209313.1228961565469
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

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%2BS ash%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.
*

------=_Part_140791_2209313.1228961565469--
Nicholas Mercier [ Do, 11 Dezember 2008 03:12 ] [ ID #1980695 ]

Re: SimpleXML broke while I was sleeping.

------=_Part_303_7161959.1228961881232
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

did they change the source at WoWhead?




2008/12/11 Nicholas Mercier <holyyakker [at] gmail.com>

> 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.--construc t>]:
> http%3A%2F%2Fwww.wowhead.com <http://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.--construc t>]:
> 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.
> *
>



--
J.A. van Zanen

------=_Part_303_7161959.1228961881232--
Jack van Zanen [ Do, 11 Dezember 2008 03:18 ] [ ID #1980696 ]

Re: SimpleXML broke while I was sleeping.

> 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%2BS ash%26xml:84:
> parser error : Entity 'nbsp' not defined in *
> /home/thered/public_html/test/config.php* on line *28

Looks like the xml contains ' ' chars now - which are not valid in
xml context it seems.

Not sure if '&nbsp;' is valid but you'll have to work it out. Take
the xml, save it to your desktop, try to show it in IE (if using windows
of course :P). It will show errors. Once you work out how to fix it,
modify your script accordingly.

--
Postgresql & php tutorials
http://www.designmagick.com/


--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
dmagick [ Do, 11 Dezember 2008 03:44 ] [ ID #1980697 ]

Re: SimpleXML broke while I was sleeping.

------=_Part_141414_1711958.1228966161546
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

Jack wins the right to call me an idiot for a long time. WoWhead changed
their configuration slightly I think, that is what messed it up. I believe
it is working now. Thank you - I was just convinced it was something dumb on
my end.

On Wed, Dec 10, 2008 at 9:44 PM, Chris <dmagick [at] gmail.com> wrote:

>
> This is the error message I now get:
>> *Warning*: SimpleXMLElement::__construct()
>> [simplexmlelement.--construct<
>> http://www.theredshirts.com/test/simplexmlelement.--construc t>]:
>> http%3A%2F%2Fwww.wowhead.com%2F%3Fsearch%3DAngelista%27s%2BS ash%26xml:84:
>> parser error : Entity 'nbsp' not defined in *
>> /home/thered/public_html/test/config.php* on line *28
>>
>
> Looks like the xml contains ' ' chars now - which are not valid in xml
> context it seems.
>
> Not sure if '&nbsp;' is valid but you'll have to work it out. Take the
> xml, save it to your desktop, try to show it in IE (if using windows of
> course :P). It will show errors. Once you work out how to fix it, modify
> your script accordingly.
>
> --
> Postgresql & php tutorials
> http://www.designmagick.com/
>
>

------=_Part_141414_1711958.1228966161546--
Nicholas Mercier [ Do, 11 Dezember 2008 04:29 ] [ ID #1980699 ]

Re: SimpleXML broke while I was sleeping.

------=_Part_1417_7792256.1228966324645
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: 7bit
Content-Disposition: inline

I'll pass.... we all have a senior moment every now and than :-)


Jack

2008/12/11 Nicholas Mercier <holyyakker [at] gmail.com>

> Jack wins the right to call me an idiot for a long time. WoWhead changed
> their configuration slightly I think, that is what messed it up. I believe
> it is working now. Thank you - I was just convinced it was something dumb
> on
> my end.
>
> On Wed, Dec 10, 2008 at 9:44 PM, Chris <dmagick [at] gmail.com> wrote:
>
> >
> > This is the error message I now get:
> >> *Warning*: SimpleXMLElement::__construct()
> >> [simplexmlelement.--construct<
> >> http://www.theredshirts.com/test/simplexmlelement.--construc t>]:
> >> http%3A%2F%2Fwww.wowhead.com <http://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
> >>
> >
> > Looks like the xml contains ' ' chars now - which are not valid in
> xml
> > context it seems.
> >
> > Not sure if '&nbsp;' is valid but you'll have to work it out. Take
> the
> > xml, save it to your desktop, try to show it in IE (if using windows of
> > course :P). It will show errors. Once you work out how to fix it, modify
> > your script accordingly.
> >
> > --
> > Postgresql & php tutorials
> > http://www.designmagick.com/
> >
> >
>



--
J.A. van Zanen

------=_Part_1417_7792256.1228966324645--
Jack van Zanen [ Do, 11 Dezember 2008 04:32 ] [ ID #1980700 ]
PHP » gmane.comp.php.database » SimpleXML broke while I was sleeping.

Vorheriges Thema: MySQLDump through PHP/HTML UI
Nächstes Thema: MS SQL error...I've come a long way to get this far