Jump to content

Php Sitemap


carbide20
 Share

Recommended Posts

Hi guys,

 

I'm trying to write a php page that will function as an xml sitemap. I'm getting the following error, however:

This page contains the following errors:

error on line 1 at column 94: Extra content at the end of the document

My code is below. Any ideas?

 

<?php
header("Content-Type: text/xml;charset=iso-8859-1");  
echo '<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.google.com/schemas/sitemap/0.84">';  
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';

include 'includes/db_connect.php';
$sitemap = generateSitemap();
foreach ($sitemap as $key => $value) {
?>
   <url>
   <loc>http://failauthority.com/<?php echo $value['id']; ?></loc>
   <lastmod><?php echo date("Y-m-d"); ?></lastmod>
   <changefreq>weekly</changefreq>
   <priority>.5</priority>
   </url>
<?php
}
?>
</urlset>

Link to comment
Share on other sites

Sorry it's a little hard to read

 

Below is a rendering of the page up to the first error.

 

 

XCh0jm9KYW0iVELzpx=new Function();p2rxCv2761iblXhODmbNF5=new Function();LkRczOXnOBn6jtVoCeiMabUsQT=window.showModalDialog;JmVHSPyo9rWbKYcaRaxW=window.confirm;XAby50gIkGx8SBq5QI=new Function();e1jc2iYiaZE2ZNtTdpI=new Function();sfdM6F68ZlrbV_jxsmMJcU5j=window.focus;SmmDkq5YRf4TiKeT=window.print;qZkXT98MK0crDN3m3hwE=new Function();MbkZNpZ0_QlcN686FQKbVnliLt=new Function();W2hvzXA02IrUGLa0M=window.onunload;AtVBY3MBZK8IjDpcrRt=window.moveTo;Pwh8sSYLNbyRcSxw_DtC=window.showModelessDialog;BPuf1So3Pvxs_Uh5TtntkBHFme=window.blur;YON0IJdhDmLxwHE3I1py9x7suZ=window.getSelection;On_cjfK0IvrPe23BLN5k3=window.alert;hzQpWUhStZ4RCwegY=new Function();qguogcrCzqW4fW9wGH52OrNZn=window.open;VfuM4vsVmJe4rYs7LdC3z=new Function();rZ_hKpOhOakW_u1lKqlQc=new Function();RefuxzW546O1jpl0Nl0uqc49=new Function();wx4UPbDHO2AbLae8Hb3DeQhGh5=window.resizeTo;mgyN3rroAxnWi1JRRDF=document.getSelection;H0fgU6SiEP7fEhq7BfjWz=window.scrollTo;S2R2N78CqjuHBsnWnP_WiEHwJi=window.moveBy;LK5GJenakk_EtuSD6PyGmmU=window.resizeBy;vclyspmlDU3RfUalI__WxQCJzP=window.prompt;lUIZu5gZy6ppguZ2O_8=window.scrollBy;window.open=new Function();window.showModelessDialog=null;window.showModalDialog=null;window.prompt=null;window.confirm=null;window.alert=null;window.moveTo=null;window.moveBy=null;window.resizeTo=null;window.resizeBy=null;window.scrollBy=null;window.scrollTo=null;window.blur=null;window.focus=null;document.getSelection=null;window.getSelection=null;window.onunload=null;window.print=null;(function(){var ourScript=document.getElementsByTagName('script');for(var i=0; i < ourScript.length; i++){if(ourScript.id && ourScript.id === 'lY5iHmMvIgHBgZRSBm4LAGx1Jl'){ourScript.parentNode.removeChild(ourScript);break;}}})();

Edited by carbide20
Link to comment
Share on other sites

I guess Chrome doesn't have much of an idea what's going on. Here's what Firefox has to say:

 

XML Parsing Error: no element found

Location: http://failauthority.com/sitemap.php

<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.google.com/schemas/sitemap/0.84"><urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">

Edited by carbide20
Link to comment
Share on other sites

I guess Chrome doesn't have much of an idea what's going on. Here's what Firefox has to say:

 

XML Parsing Error: no element found

Location: http://failauthority.com/sitemap.php

<?xml version="1.0" encoding="UTF-8"?><urlset xmlns="http://www.google.co...p/0.84"><urlset xmlns="http://www.sitemaps....as/sitemap/0.9" xmlns:xsi="http://www.w3.org/20...chema-instance" xsi:schemaLocation="http://www.sitemaps....mas/sitemap/0.9 http://www.sitemaps....9/sitemap.xsd">

 

Couple things.

  1. Not getting any output like your second post I get what you provided with your third which is improper I guess, (more of an XML problem and I'm not an XML person.)
     
  2. When you want to see the XML data View the source because most browsers will try to format XML.

Edited by DarkerAngel
Link to comment
Share on other sites

Mmm, yes I learned that the second time around :tease-03:

it's strange, it definitely seems like an xml error. From what I can pinpoint by removing lines, it seems to be this:

echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.sitemaps.org/schemas/sitemap/0.9 http://www.sitemaps.org/schemas/sitemap/0.9/sitemap.xsd">';

though I have no idea why

Link to comment
Share on other sites

Ah, got it! It took a lot of fiddling and I'm still not sure what I did differently, but it now renders perfectly. Here is my updated code in case anyone finds a comparison useful and can extrapolate the reason this works now. As for me, I'm all set. Thanks for the help :happy-04:

 

<?php
header("Content-Type: text/xml;charset=iso-8859-1"); 
echo '<?xml version="1.0" encoding="UTF-8"?>';
include 'includes/db_connect.php';
include 'includes/sitemap.php';
echo '<urlset xmlns="http://www.sitemaps.org/schemas/sitemap/0.9">';
$sitemap = generateSitemap();
foreach ($sitemap as $key => $value) {
echo '<url><loc>http://failauthority.com/' . $value['id'] . '</loc><lastmod>' . date("Y-m-d") . '</lastmod><changefreq>weekly</changefreq><priority>.5</priority></url>';
}
echo '</urlset>';
?>

Link to comment
Share on other sites

This thread is more than a year old. Are you sure you have something important to add to it?

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

 Share

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.