Jump to content

writing to google xml sitemap file


Giddy Rob

Recommended Posts

Hi,

 

I have found a nice little script to write to the xml file for google, but it appears not to be updating the file.

 

Could someone please let me know what might be wrong as this is the first time I've tried to do this.

 

$dom = new DomDocument('1.0', 'utf-8');
$dom->load('../sitemap.xml'); // if it's a string, $dom->load($xmlFile) if is a file
// create the new node element
$node = $dom->createElement('url');
// build node
$node->appendChild($dom->createElement('loc', $title));
$node->appendChild($dom->createElement('lastmode', date(Y-m-d)));
$node->appendChild($dom->createElement('changefreq', 'monthly'));
$node->appendChild($dom->createElement('priority', '2'));
// append the child node to the root
$dom->documentElement->appendChild($node);
// get the document as an XML string
$xmlStr = $dom->save();	

 

I was wondering if it was something to do with the [urlset] tag within the xml file I'm using? The xml file is just a standard google sitemap.xml

 

Any help on this would be great :)

 

Cheers

 

Rob

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

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.

×
×
  • 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.