Take the 2-minute tour ×
WordPress Development Stack Exchange is a question and answer site for WordPress developers and administrators. It's 100% free, no registration required.

I tried to find a tutorial to do that points to title. I could only find one tutorial several times, but it doesn't work for me. The tutorial is posted in various blogs, so I thought it's working (e.g. here).

It's not. I'm posting it within my single.php and I get the following error messages:

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 2: parser error : AttValue: " or ' expected in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <html lang=en> in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 2: parser error : attributes construct error in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <html lang=en> in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 2: parser error : Couldn't find end of Start Tag html line 2 in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <html lang=en> in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 2: parser error : Extra content at the end of the document in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <html lang=en> in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php:76 Stack trace: #0 /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php(76): SimpleXMLElement->__construct('<!DOCTYPE html>...') #1 /home/zoomingj/public_html/wp-includes/template-loader.php(43): include('/home/zoomingj/...') #2 /home/zoomingj/public_html/wp-blog-header.php(16): require_once('/home/zoomingj/...') #3 /home/zoomingj/public_html/index.php(17): require('/home/zoomingj/...') #4 {main} thrown in /home/zoomingj/public_html/wp-content/themes/alltuts-child/single.php on line 76

Is it that I just cannot use that kind of code within the single.php? I also tried to put the code in my function.php instead, but it gave me the exact same error messages.

If this doesn't work, do you know about any other code that is likely to work within the single.php then?

EDIT:

The code snippet I wanted to insert:

<?php
//get cool feedburner count
$whaturl="http://api.feedburner.com/awareness/1.0/GetFeedData?uri=your feedburner id";

//Initialize the Curl session
$ch = curl_init();

//Set curl to return the data instead of printing it to the browser.
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);

//Set the URL
curl_setopt($ch, CURLOPT_URL, $whaturl);

//Execute the fetch
$data = curl_exec($ch);

//Close the connection
curl_close($ch);
$xml = new SimpleXMLElement($data);
$fb = $xml->feed->entry['circulation'];
echo $fb;
//end get cool feedburner count
?>

In line76: $xml = new SimpleXMLElement($data);

Thanks a lot in advance.

share|improve this question
    
That error refers to line 76. What line, in your single.php file, is line 76? Can you post the exact code you're trying to include in single.php? –  GavinR Nov 11 '11 at 5:29
    
See updated question. Thank you. –  japanworm Nov 11 '11 at 5:33
add comment

1 Answer

up vote 1 down vote accepted

Chances are your server has magic quotes turned on. Try changing line 76 to:

$xml = new SimpleXMLElement(stripslashes($data));

(via DGrigg)

share|improve this answer
    
I tried adding the code I posted above into various spots of my templates and finally got it to work. I have no clue what was causing the problem. Thank you very much for trying! :) –  japanworm Nov 11 '11 at 15:05
    
Is this quite a crappy code or is there something else interfering as I get "0" subscribers all of a sudden, so it doesn't always seem to get the right number. I've seen the same issue on other people's websites, too. Is there some kind of hack to make sure it always displays the correct number and not "0"? –  japanworm Nov 12 '11 at 11:44
    
Never mind, I found a somewhat good solution for the earlier mentioned problem: techpp.com/2009/03/24/… .. it's still annoying as you have to change the number by hand if your subscribers are growing rapidly. If there's a more elegant solution, I'd be happy to hear it :) –  japanworm Nov 12 '11 at 12:17
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.