WordPress.org

Forums

Yoast SEO
URL Encoding on sitemaps (8 posts)

  1. felipelavinz
    Member
    Posted 2 years ago #

    WordPress version: 3.5.1
    WordPress SEO version: 1.4.7

    I did this: got an xml parsing error from Google Webmaster Tools

    I expected the plugin to do this: output valid xml :-)

    Instead it did this: applied quick fix

    ---

    Hi

    I recently found out from Google Webmaster Tools that some of my sitemaps where not being indexed because of a xml parsing error.

    The problem was that some of my URLs had ampersands that weren't encoded, so taking a look at the plugin I tried a quick fix. On class-sitemaps.php, find the sitemap_url method and just before defining the $output, add:

    $url['loc'] = htmlspecialchars( $url['loc'] );

    This complies with the Sitemap protocol as defined on http://www.sitemaps.org/protocol.html#escaping

    Hope you can add it to the plugin to solve this for others that might have the same issue.

    http://wordpress.org/extend/plugins/wordpress-seo/

  2. johnzenausa
    Member
    Posted 2 years ago #

    Can you tell me what line to put it on? There is a ton of $output in the file.

  3. felipelavinz
    Member
    Posted 2 years ago #

    Around line 553:

    function sitemap_url( $url ) {
    		if ( isset( $url['mod'] ) )
    			$date = mysql2date( "Y-m-d\TH:i:s+00:00", $url['mod'] );
    		else
    			$date = date( 'c' );
    		$url['loc'] = htmlspecialchars( $url['loc'] );
    		$output = "\t<url>\n";
  4. johnzenausa
    Member
    Posted 2 years ago #

    It worked for one of the pages but on the following sitemap page I still get the following error:

    XML Parsing Error: junk after document element
    Location: http://www.digitalcamerasmegastore.com/post-sitemap6.xml
    Line Number 2, Column 1:<b>Fatal error</b>:  Unknown: Cannot use output buffering in output buffering display handlers in <b>Unknown</b> on line <b>0</b><br />
    ^
  5. felipelavinz
    Member
    Posted 2 years ago #

    That's a separate issue, a fatal error about something related with output buffers... Anyway, I just took a look at your sitemap and it seems fine now

  6. johnzenausa
    Member
    Posted 2 years ago #

    What I did was lower the pages from 1000 per page to 500 and everything started working with or without the above code. Interesting.

  7. johnzenausa
    Member
    Posted 2 years ago #

    I mean I lowered the links from the default 1000 to 500.

  8. felipelavinz
    Member
    Posted 2 years ago #

    Yup, that's a separate issue, perhaps related to memory consumption

Topic Closed

This topic has been closed to new replies.

About this Plugin

  • Yoast SEO
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic

Tags