# Diskussioner→ Caught exception: String could not be parsed as XML

• m0nkiii sa...
• Användare
• 18 feb 2009, 12:57

#### Caught exception: String could not be parsed as XML

I get this exception many times. Got this on:
http://www.last.fm/music/A Day to Remember/_/Another Song About The Weekend
http://www.last.fm/music/A Better Hope Foundation/_/Trading Heroes for Ghosts
http://www.last.fm/music/A Better Hope Foundation/_/Glutton For Punishment

This I got for http://www.last.fm/music/Break/_/Day One
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 18: parser error : xmlParseEntityRef: no name in /home/xnffasen/public_html/lastfm/lastfmapi/lastfmapi/class/apibase.php on line 36Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <name>drum & bass</name> in /home/xnffasen/public_html/lastfm/lastfmapi/lastfmapi/class/apibase.php on line 36Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/xnffasen/public_html/lastfm/lastfmapi/lastfmapi/class/apibase.php on line 36Caught exception: String could not be parsed as XML

and so on.

What is causing the exception?

• Användare
• 19 feb 2009, 18:46
Me too, with the same exception. Seems that In my case it has something to do with special characters as #3 shows. Maybe the stack trace will be of some help, so I post it here:

PHP Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in www\lastfm\mustats\lib\lastfmapi\class\apibase.php:36Stack trace:#0 lastfm\mustats\lib\lastfmapi\class\apibase.php(36): SimpleXMLElement->__construct('')#1 lastfm\mustats\lib\lastfmapi\api\track.php(118): lastfmApiBase->apiGetCall(Array)#2 lastfm\mustats\mu_collectr.php(324): lastfmApiTrack->getInfo(Array)#3 lastfm\mustats\mu_collectr.php(440): get_trackdata('H??roes del Sil...', 'Entre Dos Tierr...')#4 {main} thrown in lastfm\mustats\lib\lastfmapi\class\apibase.php on line 36

Clueless for the moment.

• I keep seeing this as well but I'm not certain what causes it. It can sometimes fix itself just with a page refresh which is odd.

I'll look into it, and thanks for the stack trace :)

Matt

Online Last.FM Player (Updated version is SVN only currently)
• It seems to happen when there is a loss of connection or a connection error. I'll look into adding in some code to catch this sort of error when it happens and try and automitically get past it if possible.

Online Last.FM Player (Updated version is SVN only currently)
• Användare
• 21 feb 2009, 10:38
Hi Matt, thx for the quick reaction (and of course for the great work you are doing). I started the script again a few minutes after the error occured and it was gone. Seems this happens with general connection problems or when lastfm is very busy, I guess.

One always has to reckon with this sort of things and react properly, so it would be great if this error was manageable via your error routines and the script didn't abort.

What to do, after this sort of error occurs will be different for every program, I think. In my case, I'm thinking of doing a retry after a while, and if the problem still exists do a clean exit, and write some sort of log. Bye for now and thanks again ... Theo.

• I tryed adding in some sort of error but it always seems to ignore it and output that strange one instead. I'm working on it though.