
|
View Full Version : XML Parsing Error
amsterdamn 09-30-2003, 01:02 PM I'm getting this error on my RSS feed links:XML Parsing Error: xml processing instruction not at start of external entity
Location: http://post911timeline.org/xml-rss2.php
Line Number 4, Column 1:
<?xml version="1.0" encoding="ISO-8859-1"?>
^This is very strange because it has worked fine for so long and I haven't changed a thing. It makes me think there may be something different on the server that causes this....but, of course, I dunno what I'm talking about. I know that when I run both links thru feedvalidator.org (http://feedvalidator.org/), it tells me that there are three empty lines. Here are those links:
post911timeline.org/xml-rss.php (http://post911timeline.org/xml-rss.php)
&
post911timeline.org/xml-rss2.php (http://post911timeline.org/xml-rss2.php)
I'm seeking help on other forums also, but so far nobody can tell me what is wrong. I have also searched on Google, but have not found anything there either. Can anybody here help me?
ScottD 09-30-2003, 01:06 PM feedvalidator.org is right, there are three blank lines at the top of the file.
In your xml-rss.php script, make sure there is no whitespace before you start writing the XML data.
amsterdamn 09-30-2003, 01:34 PM Originally posted by DizixCom
make sure there is no whitespace before you start writing the XML data
That is what is so strange...there is no empty space before or after...like I said, it used to work just fine and I have made no changes.
ScottD 09-30-2003, 01:35 PM Any chance you can post the code to the xml-rss.php script? Something is writing those three blink lines, though it's impossible to say what without actually seeing it.
amsterdamn 09-30-2003, 02:06 PM This is xml-rss.php:<?
/**
* Nucleus: PHP/MySQL Weblog CMS (http://nucleuscms.org/)
* Copyright (C) 2002 The Nucleus Group
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
* (see nucleus/documentation/index.html#license for more info)
*
* Nucleus RSS syndication channel skin
*/
header("Pragma: no-cache");
// $CONF['Self'] = $PHP_SELF;
$CONF['Self'] = "xml-rss.php";
include('config.php');
if (!$CONF['DisableSite']) {
// get feed into $feed
ob_start();
selectSkin('xmlrss');
selector();
$feed = ob_get_contents();
ob_end_clean();
// create ETAG (hash of feed)
$eTag = md5($feed);
header('Etag: "'.$eTag.'"');
// compare Etag to what we got
// TODO: serverVar doesn't seem to work :((
if ($eTag == serverVar('HTTP_IF_NONE_MATCH')) {
header("HTTP/1.0 304 Not Modified");
header('Content-Length: 0');
} else {
// dump feed
echo $feed;
}
} else {
// output empty RSS file...
// (because site is disabled)
echo '<' . '?xml version="1.0" encoding="ISO-8859-1"?' . '>';
?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
<channel>
<title><?=htmlspecialchars($CONF['SiteName'])?></title>
<link><?=htmlspecialchars($CONF['IndexURL'])?></link>
<description></description>
<docs>http://backend.userland.com/rss091</docs>
</channel>
</rss>
<?
}
?>
selectSkin('xmlrss'); refers to a skin template in the Nucleus control panel:<?xml version="1.0" encoding="ISO-8859-1"?>
<!DOCTYPE rss PUBLIC "-//Netscape Communications//DTD RSS 0.91//EN" "http://my.netscape.com/publish/formats/rss-0.91.dtd">
<rss version="0.91">
<channel>
<title><%blogsetting(name)%></title>
<link><%blogsetting(url)%></link>
<description><%blogsetting(desc)%></description>
<docs>http://backend.userland.com/rss091</docs>
<language>en</language>
<image>
<url><%adminurl%>nucleus2.gif</url>
<title><%blogsetting(name)%></title>
<link><%blogsetting(url)%></link>
</image>
<%blog(xmlrss,10)%>
</channel>
</rss>
ScottD 09-30-2003, 02:23 PM Is there anything in config.php that might lead to whitespace being written? It could be something as simple as empty lines before or after the <? ?>'s.
amsterdamn 09-30-2003, 02:37 PM I don't think so...here ya go:<?
// mySQL connection information
$MYSQL_HOST = 'XXXXX';
$MYSQL_USER = 'XXXXX';
$MYSQL_PASSWORD = 'XXXXX';
$MYSQL_DATABASE = 'XXXXX';
// main nucleus directory
$DIR_NUCLEUS = '/home/XXXXX/public_html/nucleus/';
// path to media dir
$DIR_MEDIA = '/home/XXXXX/public_html/media/';
// extra skin files for imported skins
$DIR_SKINS = '/home/XXXXX/public_html/skins/';
// these dirs are normally sub dirs of the nucleus dir, but
// you can redefine them if you wish
$DIR_PLUGINS = $DIR_NUCLEUS . "plugins/";
$DIR_LANG = $DIR_NUCLEUS . "language/";
$DIR_LIBS = $DIR_NUCLEUS . "libs/";
// include libs
include($DIR_LIBS.'globalfunctions.php');
?>
ScottD 09-30-2003, 02:44 PM Haha, wow, now we have to see globalfunctions.php. :D
Dontcha love debugging problems like this? They're soooo bloody irritating!
amsterdamn 09-30-2003, 03:10 PM Loads of fun! ;) Thanks for your help so far! The file is too big to post here, but I can attach a txt file for you....
ScottD 09-30-2003, 03:17 PM Well dang, there's nothing there either.
Something, somewhere is inserting those blank lines. I can't see it though so I'm without clue.
Kattilyn 09-30-2003, 03:22 PM I'm totally unfamiliar with XML, but could it be due to the fact that you're calling Header() prior to the first XML thing?
Burhan 09-30-2003, 04:54 PM Instead of trying to figure out where the whitespace is coming from, just get rid of it. Here is what I used when I wrote my XML parsing class :
$data=eregi_replace(">"."[[:space:]]+"."<","><",$data);
Where $data was a line being read from a file.
Hope this helps.
PS, I think the problem is with your echo statement in your else block right before you echo the declaration. If $feed is empty, it might be spitting out spaces.
amsterdamn 09-30-2003, 09:26 PM fyrestrtr,
Could you tell me exactly where to put that line of code in the code I've posted above? I have tried in different places, but so far no luck.
Thanks
Burhan 10-01-2003, 12:40 AM Well, you'd have to modify your code a bit. You would have to scan your entire rss feed and then strip the whitespaces out of it.
If you don't want to do that, you can eliminate a few problem spots by getting rid of the extra whitespace in your code. (as in after the echoing of the xml declaration).
If you want to use my snippet, you would have to read the outputted rss file, and then trim the whitespace out, like this :
while ($data = fread($fp, 4096))
{
$data=eregi_replace(">"."[[:space:]]+"."<","><",$data);
fwrite($fp,$data);
}
Where $fp is your rss feed opened in read/write mode.
Or you could read your entire file into an array (using file()) and then write it back out stripping the whitespace.
A few options there :)
|