I'm with several errors
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: /home/lineage/public_html/acp/xml/banners.xml:48: parser error : Opening and ending tag mismatch: banner line 33 and list in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: </list> in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: ^ in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: /home/lineage/public_html/acp/xml/banners.xml:48: parser error : Premature end of data in tag banner line 26 in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: </list> in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: ^ in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: /home/lineage/public_html/acp/xml/banners.xml:48: parser error : Premature end of data in tag banner line 19 in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: </list> in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: ^ in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: /home/lineage/public_html/acp/xml/banners.xml:48: parser error : Premature end of data in tag list line 2 in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: </list> in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: simplexml_load_file() [<a href='function.simplexml-load-file'>function.simplexml-load-file</a>]: ^ in /home/lineage/public_html/acp/core.php on line 191
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Notice: Trying to get property of non-object in /home/lineage/public_html/acp/core.php on line 206
[23-Aug-2013 15:35:20 America/Sao_Paulo] PHP Warning: Invalid argument supplied for foreach() in /home/lineage/public_html/acp/core.php on line 197
I took this system ever made but it does not know what it is happening!
line: 197 core.php
foreach ($this->getAll() as $banner) {
line: 191 core.php
$_xmlBanners = simplexml_load_file(PATH_XML."banners.xml");
Baners.xml:
<?xml version="1.0" encoding="UTF-8"?>
<list>
<banner id="1">
<image>http://lineagefree.com/acp/images/l2jbr.png</image>
<link>http://l2j.lt/topai/balsuoti-7907.php</link>
<votes>
<link>http://l2j.lt/topai/mokamas-7907.php</link>
<regexp><div class='list_8' style="font-weight: bold">(.*)</div></regexp>
</votes>
</banner>
<banner id="2">
<image>http://lineagefree.com/acp/images/top100mmorpg.png</image>
<link>http://l2j.lt/topai/balsuoti-7907.php</link>
<votes>
<link>http://l2j.lt/topai/mokamas-7907.php</link>
<regexp><div class='dlist_8' style="font-weight: bold">(.*)</div></regexp>
</votes>
</banner>
<banner id="3">
<image>http://lineagefree.com/acp/images/gamesitestop100.jpg</image>
<link>http://l2j.lt/topai/balsuoti-7907.php</link>
<votes>
<link>http://l2j.lt/topai/mokamas-7907.php</link>
<regexp><div class='dlist_8' style="font-weight: bold">(.*)</div></regexp>
</votes>
<banner id="4">
<image>http://lineagefree.com/acp/images/arenatop100.png</image>
<link>http://l2j.lt/topai/balsuoti-7907.php</link>
<votes>
<link>http://l2j.lt/topai/mokamas-7907.php</link>
<regexp><div class='dlist_8' style="font-weight: bold">(.*)</div></regexp>
</votes>
<banner id="5">
<image>http://lineagefree.com/acp/images/mmorpglist.jpg</image>
<link>http://l2j.lt/topai/balsuoti-7907.php</link>
<votes>
<link>http://l2j.lt/topai/mokamas-7907.php</link>
<regexp><div class='dlist_8' style="font-weight: bold">(.*)</div></regexp>
</votes>
<banner id="6">
<image>http://lineagefree.com/acp/images/top200.gif</image>
<link>http://l2j.lt/topai/balsuoti-7907.php</link>
<votes>
<link>http://l2j.lt/topai/mokamas-7907.php</link>
<regexp><div class='dlist_8' style="font-weight: bold">(.*)</div></regexp>
</votes>
</banner>
</list>
follows all data. if you need any more please ask me.
I'm desperate.
Sorry my english. was done with google!
The error message Opening and ending tag mismatch: banner line 33 and list is telling you that while parsing the XML file, the parser found an opening tag <banner>, and then some nested content, but when it was expecting the matching end tag </banner> it found a different end tag, </list>.
This generally happens when you have a tag opened somewhere that you never close, meaning the parser is still waiting for you to close it when it gets to the close of some outer block.
In this case, you can look through your XML and see that there are 6 opening <banner> tags, but only 3 closing </banner>, so something's clearly gone wrong.
In fact, you just seem to be missing the </banner> at the end of the banners with IDs 3, 4, and 5.
Related
below code is not working on one server, but working fine in others. I am getting this error:
Warning: simplexml_load_string(): Entity: line 1: parser error : Opening and ending tag mismatch: HR line 1 and body in testchecker.php on line 11
Warning: simplexml_load_string(): dden.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/5.5.20</h3></body> in testchecker.php on line 11
Warning: simplexml_load_string(): ^ in testchecker.php on line 11
Warning: simplexml_load_string(): Entity: line 1: parser error : Opening and ending tag mismatch: HR line 1 and html in testchecker.php on line 11
Warning: simplexml_load_string(): Entity: line 1: parser error : Premature end of data in tag body line 1 in testchecker.php on line 11
Warning: simplexml_load_string(): Entity: line 1: parser error : Premature end of data in tag html line 1 in testchecker.php on line 11
Warning: Invalid argument supplied for foreach() in testchecker.php on line 12
<?php
set_time_limit(0);
$url="http://test";
$ch = curl_init();
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
$data = curl_exec($ch);
curl_close($ch);
$xml = simplexml_load_string($data);
foreach($xml->User as $child){
echo $child->Id."<br/>";
}
?>
I dont understand why this error is getting, because in local and other servers its working fine. On dreamhost, its not. Can anybody help me in this.
The error message already tells you, what is wrong
Warning: simplexml_load_string(): Entity: line 1: parser error : Opening and ending tag mismatch: HR line 1 and body in testchecker.php on line 11
Warning: simplexml_load_string(): dden.</u></p><HR size="1" noshade="noshade"><h3>Apache Tomcat/5.5.20</h3></body> in testchecker.php on line 11
XML requires all tags be closed, while with HTML, you can omit the closing tag occasionally.
In this case, you have a <hr> tag without a corresponding closing tag. This is perfectly valid in HTML. However, it is not well-formed XML, which is required by simplexml_load_string
Description
Takes a well-formed XML string and returns it as an object.
I have fixed the issue.
The ip was blocked, so forbidden message was getting, instead of xml.
Unblocking the ip fixed everything.
I want to know to get components from rss using php.
I have created a php code, when I was running it on wampsever it was running well but when I ran it on my website this error was showing
PHP code is
<?php
$feeds = array('http://feeds.feedburner.com/ndtvnews-top-stories?format=xml');
foreach( $feeds as $feed ) {
$xml = simplexml_load_file($feed);
foreach($xml->channel->item as $item)
{
$date_format = "j-n-Y"; // 7-7-2008
$link = $item->link;
echo date($date_format,strtotime($item->pubDate));
echo ''.$item->title.'';
echo '<div>' . $item->description . '</div>';
}
}
?>
and Error is
PHP Error Message
Warning: simplexml_load_file() [function.simplexml-load-file]:
http://feeds.feedburner.com/ndtvnews-top-stories?format=xml:1: parser
error : Document is empty in /home/a7989425/public_html/rss.php on
line 5
PHP Error Message
Warning: simplexml_load_file() [function.simplexml-load-file]: in
/home/a7989425/public_html/rss.php on line 5
Free Web Hosting
PHP Error Message
Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in
/home/a7989425/public_html/rss.php on line 5
PHP Error Message
Warning: simplexml_load_file() [function.simplexml-load-file]:
http://feeds.feedburner.com/ndtvnews-top-stories?format=xml:1: parser
error : Start tag expected, '<' not found in
/home/a7989425/public_html/rss.php on line 5
PHP Error Message
Warning: simplexml_load_file() [function.simplexml-load-file]: in
/home/a7989425/public_html/rss.php on line 5
PHP Error Message
Warning: simplexml_load_file() [function.simplexml-load-file]: ^ in
/home/a7989425/public_html/rss.php on line 5
PHP Error Message
Warning: Invalid argument supplied for foreach() in
/home/a7989425/public_html/rss.php on line 7
please help
thanks
This question already has an answer here:
SimpleXMLElement error but xml is valid [closed]
(1 answer)
Closed 7 years ago.
I have this error when I am reading XML:
Warning: SimpleXMLElement::__construct(): Entity: line 1: parser error : Start tag expected, '<' not found
Warning: SimpleXMLElement::__construct(): feed.xml
Warning: SimpleXMLElement::__construct(): ^
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in #1 {main} thrown
PHP:
$feed = new SimpleXMLElement("feed.xml");
echo $feed->SHOPITEM[0]->ID_PRODUCT;
XML:
<?xml version="1.0" encoding="utf-8"?>
<PRODUCTS>
<SHOPITEM>
<ID_PRODUCT><![CDATA[121110]]></ID_PRODUCT>
</SHOPITEM>
<SHOPITEM>
<ID_PRODUCT><![CDATA[121111]]></ID_PRODUCT>
</SHOPITEM>
</PRODUCTS>
Error is on the line where is new SimpleXMLElement("feed.xml) released. Where can be the problem? The XML file is valid.
load the file like this
<?php
$feed = new SimpleXMLElement("xml.xml",null,true);
echo $feed->SHOPITEM[0]->ID_PRODUCT;
//prints 121110
see docs here http://php.net/manual/en/simplexmlelement.construct.php
Use TRUE to specify that data is a path or URL to an XML document instead of string data.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 9 years ago.
Improve this question
I was testingsimplexml_load_string() func.
<?php
ini_set('display_errors', '1');
$test = stripslashes($_POST['xml']);
$testing = simplexml_load_string($test);
print_r($testing);
?>
After the execution following error occurred, even if i am striping slashes.
Warning: simplexml_load_string(): Entity: line 1: parser error : Malformed declaration expecting version in /var/www/check.php on line 5
Warning: simplexml_load_string(): <?xml encoding='utf8'?><!DOCTYPE a[<!ENTITY e SYSTEM '/etc/passwd'>]><a>&e;</a> in /var/www/check.php on line 5
Warning: simplexml_load_string(): ^ in /var/www/check.php on line 5
Warning: simplexml_load_string(): Entity: line 1: parser error : Blank needed here in /var/www/check.php on line 5
Warning: simplexml_load_string(): <?xml encoding='utf8'?><!DOCTYPE a[<!ENTITY e SYSTEM '/etc/passwd'>]><a>&e;</a> in /var/www/check.php on line 5
Warning: simplexml_load_string(): ^ in /var/www/check.php on line 5
Warning: simplexml_load_string(): Entity: line 1: parser error : Entity 'e' not defined in /var/www/check.php on line 5
Warning: simplexml_load_string(): <?xml encoding='utf8'?><!DOCTYPE a[<!ENTITY e SYSTEM '/etc/passwd'>]><a>&e;</a> in /var/www/check.php on line 5
Warning: simplexml_load_string(): ^ in /var/www/check.php on line 5
How i can solve this error ?
I think that xml file you are trying to convert has a bad format. You can try the example that there is in official doc here in the first example and then try to fit your XML file to be like that.
I've been trying for the past couple of days to figure out why my code works perfectly locally but fails when deployed on a production server.
My local testing environment is the latest MAMP on a 10.7.2 Lion iMac.
Basically I need to fetch certain XML RSS data from Artistdata.com in order to insert it into a simple PHP-driven, non-CMS website I'm working on.
<!DOCTYPE html>
<html>
<head>
<title>RSS FEED Parser</title>
</head>
<body>
<?php
ini_set('display_errors',1);
ini_set('display_startup_errors',1);
error_reporting(-1);
# RSS Feed parser #
function getFeed($feed_url) {
$content = file_get_contents($feed_url);
$x = new SimpleXmlElement($content);
foreach ($x->show as $showEntry) {
echo '<div>';# date
$newDate = new DateTime($showEntry->date);
echo date_format($newDate, 'l, F j, Y');
echo '</div>';# /date
# further data fetching, totally unrelated
# to the problem that I'm experiencing
}
}
?>
<!-- START FEED PARSING -->
<div id="feed-data">
<?php getFeed('http://feeds.artistdata.com/xml.shows/artist/AR-30CA266E4BEDD78F/xml/future'); ?>
</div>
<!-- END FEED PARSING -->
</body>
</html>
I'm sure there are more people who had similar problems but I've yet to find a viable solution.
If you have any pointers I'd be very grateful.
EDIT: Forgot to post the errors, so here they are below
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : Space required after the Public Identifier in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : SystemLiteral " or ' expected in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 1: parser error : SYSTEM or PUBLIC, the URI is missing in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML 2.0//EN"> in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 9: parser error : Opening and ending tag mismatch: hr line 7 and body in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: </body></html> in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 9: parser error : Opening and ending tag mismatch: body line 4 and html in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: </body></html> in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: Entity: line 10: parser error : Premature end of data in tag html line 2 in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: in /home/*****/public_html/ssr/parse-feed.php on line 17
Warning: SimpleXMLElement::__construct() [simplexmlelement.--construct]: ^ in /home/*****/public_html/ssr/parse-feed.php on line 17
Fatal error: Uncaught exception 'Exception' with message 'String could not be parsed as XML' in /home/*****/public_html/ssr/parse-feed.php:17 Stack trace: #0 /home/*****/public_html/ssr/parse-feed.php(17): SimpleXMLElement->__construct('<!DOCTYPE HTML ...') #1 /home/*****/public_html/ssr/parse-feed.php(33): getFeed('http://feeds.ar...') #2 {main} thrown in /home/*****/public_html/ssr/parse-feed.php on line 17
Problem solved, I was using the wrong feed, the correct one is http://artistdata.sonicbids.com/john-latini/shows/xml/future
That XML does not look like RSS. It is an specific format defined by http://feeds.artistdata.com/_css/shows.xsd.
The error messages all say that you get an HTML (2.0) page not a XML. I can not reproduce that, I get the XML using file_get_contents().
Try to output the HTML page, maybe it has some more information.
echo file_get_contents('http://feeds.artistdata.com/xml.shows/artist/AR-30CA266E4BEDD78F/xml/future');