我试图找到一个教程来做这件事,指向标题。我只能找到一个教程几次,但它不适合我。该教程发布在各种博客上,所以我认为它是有效的(例如。here).
事实并非如此。我把它贴在我的单曲里。php和我收到以下错误消息:
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
是不是因为我不能在单一代码中使用这种代码。php?我还尝试将代码放入我的函数中。php,但它给了我完全相同的错误消息。
如果这不起作用,那么您是否知道任何其他可能在单个中起作用的代码。那么php呢?
编辑:
我要插入的代码段:
<?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
?>
第76行:
$xml = new SimpleXMLElement($data);
提前非常感谢。