5

Drupal version: 7.14

Views RSS version: 7.x-2.0-rc3

I am trying to validate an RSS feed in feedburner for a drupal blog. When I try to validate de xml file at feedvalidator.org I get this error

line 3, column 0: XML parsing error: <unknown>:3:0: XML or text declaration not at start of entity

The xml file is well written (I compared it against another one which validated) and the error I found is that that xml file generated by Views RSS puts three blank lines at the beginning and therefore I think the file does not validate.

drupal feed not validated

I've looked for answers in the oficial Views RSS module issue track but unsuccessfully. I've also created many feed views using Views RSS module, but all of them provide the same error at feedvalidator.org.

I'd like to correct this through the source code of the module, but I do not know where to start or which file I should edit to correct that mistake, just if only through code I could solve this validation.

2
  • 1
    Can you double check in /sites/all/modules/views_rss/theme/views-view-views-rss.tpl.php there there isn't any random lines or anything at the top? Add <?php print 'hi'; ?> at the very top (before the first line) and see if hi is printed above or below the 2 line gap.
    – Steven
    Commented Sep 19, 2013 at 17:25
  • I inserted the test code you sugested but it did not worked. There is no "hi" in the file
    – Francisco
    Commented Sep 20, 2013 at 15:53

5 Answers 5

1

In some cases this error will be caused by space in one of your modules. Best way to find the issue is to edit module.inc file in includes folder and add this after the drupal_load function in the module_load_all function:

print $module.'|';

you will probably get a huge list but one that starts on line 3 will be the issue.

3
  • I did this and got the list of modules printed in the web and this code Warning: Cannot modify header information - headers already sent by (output started at /home/ozone/ecommerce_drupal/releases/20120324153140/includes/module.inc:26) in drupal_send_headers() (line 1243 of /home/ozone/ecommerce_drupal/releases/20120324153140/includes/bootstrap.inc).
    – Francisco
    Commented Sep 19, 2013 at 20:22
  • What is on line 3? that error? Can you put on pastebin or somewhere full output.
    – pgrujic
    Commented Sep 20, 2013 at 15:00
  • I got this two sceneraios. First, this is the list of modules. Follow the link image The other one is the error I mentioned. Follow the link image
    – Francisco
    Commented Sep 20, 2013 at 15:59
1

The cause of the problem is a 'SPACE' at the beginning of a unknown module script.

  1. Find the script causing this problem:

    grep -n -o -R \ \<\?php * |grep :1:

  2. Delete 'SPACE' at the beginning of the found script

  3. Delete Cache

0

Try changing the file Steven mentioned in the comments (views_rss/theme/views-view-views-rss.tpl.php) from this

<?php
/**
 * @file views-view-views-rss.tpl.php
 * Default template for feed displays that use the RSS Fields style.
 */
?>
<?php print "<?xml"; ?> version="1.0" encoding="utf-8" <?php print "?>"; ?>
<?php print $rss_feed; ?>

to this

<?php
/**
 * @file views-view-views-rss.tpl.php
 * Default template for feed displays that use the RSS Fields style.
 */
?><?php print "<?xml"; ?> version="1.0" encoding="utf-8" <?php print "?>"; ?>
<?php print $rss_feed; ?>

If that does work, I'm sure the views_rss maintainers would be very grateful if you'd submit a patch :)

4
  • What is exactly the difference? Is there a time I should wait to see changes reflected? I edited the file but nothing happened.
    – Francisco
    Commented Sep 19, 2013 at 19:39
  • The only difference is moving the first print line up to immediately after the previous closing tag, in case there's a character there accounting for the whitespace. I guess not but it was worth a shot
    – Clive
    Commented Sep 19, 2013 at 19:51
  • Did doing what Clive said help? If not try adding the <?php print 'hi'; ?> to that file and so what I said above.
    – Steven
    Commented Sep 20, 2013 at 16:47
  • @Steven No, it did not worked. Not printing "hi" nor what Clive sugested
    – Francisco
    Commented Sep 20, 2013 at 20:30
0

I'd like to add more insight about @pgrujic solution. We use Services to generate custom RSS feeds and we faced the exact same problem with blank spaces at the beginning of the XML document. Once you added the following line of code to the file -

print $module.'|';
  • It printed out a line with the name of modules separated by a pipeline. You'll have to find a blank space before of a name of any module.

For example, if you find something like this:

ckeditor| color|comment|

It means the color module has a blank space. Remove it and happy feed!

Sorry, couldn't reply in the same treat because the low reputation

0

It mostly due to spaces at start before <?php tag in module or no ending tag in tpl file.

Mostly it is module file so...

grep -R -H '^  <?php' modules/**/*.module

This will check all module files withing your module folder ( i am a step back in my sites/all folder in my linux terminal to find culprit.) If you find two spaces leave two space between ^ and

If you just get the filename you can find its path via

locate -br 'culprit.module'

After correcting clear cache. :)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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