Errors with simplexml_load_string
| Project: | Blog reactions |
| Version: | 6.x-1.x-dev |
| Component: | Code |
| Category: | bug report |
| Priority: | normal |
| Assigned: | sanduhrs |
| Status: | closed |
Jump to:
I noticed that I had multiple PHP errors in my watchdog table in a row, coming from the Blog Reactions module. The associated url that it happened on was 'http://blog.davereid.net/content/treasurydirect-too-much-security'. From what I can tell, the simple_xml_load_string got fed an actual HTML page instead of XML in the blog_reactions_fetch_bloglines() function. Maybe a check for $request->code == '200' should be added. I'll keep an eye on this and see if I can duplicate this.
Errors:
simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : Space required after the Public Identifier in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: ^ in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : SystemLiteral " or ' expected in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: ^ in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: Entity: line 1: parser error : SYSTEM or PUBLIC, the URI is missing in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: ^ in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: Entity: line 17: parser error : Opening and ending tag mismatch: hr line 15 and body in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: </body></html> in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: ^ in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: Entity: line 17: parser error : Opening and ending tag mismatch: body line 4 and html in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: </body></html> in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: ^ in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: Entity: line 18: parser error : Premature end of data in tag html line 2 in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.
simplexml_load_string() [function.simplexml-load-string]: ^ in /home/.katona/davereid20/drupal-6/sites/all/modules/blog_reactions/blog_reactions.module on line 333.

#1
I also get tons of these in my log file (running blog reactions 6.x-1.6). A few examples:
simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]: tp://www.thefreedictionary.com/';return true" onmouseout="status=''">""</a>&nbsp in /drupal-6.6/modules/blog_reactions/blog_reactions.module on line 235.simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]: Entity: line 98: parser error : Entity 'nbsp' not defined in /drupal-6.6/modules/blog_reactions/blog_reactions.module on line 235.simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]: Entity: line 98: parser error : EntityRef: expecting ';' in /drupal-6.6/modules/blog_reactions/blog_reactions.module on line 235.simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]: ^ in /drupal-6.6/modules/blog_reactions/blog_reactions.module on line 235.simplexml_load_string() [<a href='function.simplexml-load-string'>function.simplexml-load-string</a>]: arget="_new" href="http://www.thefreedictionary.com/_/partner.aspx?pid=abrt&word in /drupal-6.6/modules/blog_reactions/blog_reactions.module on line 235.#2
I think the problem occurs as soon as Technorati doesn't return a result. In my case it happened looking up http://feeds.technorati.com/search/http://bee5.de. If you search for it manually you'll get a result. But the cron didn't get the same result. I've added the following line to blog_reactions_fetch_technorati() right after
$xml = simplexml_load_string($response->data):watchdog('blog_reactions', $feed_url." -- ".$response->data);The returned HTML code looks like this (just a small snippet):
<?xml version="1.0" encoding="utf-8"?><rss version="2.0" xmlns:tapi="http://api.technorati.com/dtd/tapi-002.xml">
<channel>
<title></title>
<link></link>
<description></description>
<pubDate>Mon, 05 Jan 2009 07:20:12 -0800</pubDate>
<generator>Technorati v1.0</generator>
<image>
<url>http://static.technorati.com/pix/logos/logo_sm.gif</url>
<title>Technorati logo</title>
<link></link>
</image>
<webMaster>support@technorati.com (Technorati Support)</webMaster>
<docs>http://blogs.law.harvard.edu/tech/rss</docs>
<ttl>60</ttl>
<div id="main">
<div id="search-results-content">
<div class="module"><div class="module-inner">
<h1>Posts about <span class="subject"></span></h1>
</div>
</div>
</div>
</channel>
</rss>
As you can see something is returned by Technorati but nothing useful. So IMHO we have to check $response->data before we use simplexml_load_string(). I've seen that the title tag is empty...
#3
Temporarily you can hide the PHP error by adding an @ to the following line:
@$xml = simplexml_load_string($response->data);Maybe we can add another condition to check if $xml is an object or not FALSE...
#4
Fixed that issue in 5-dev, 6-dev.
Thanks.
#5
status update.
#6
Automatically closed -- issue fixed for 2 weeks with no activity.