Giddy Rob Posted April 25, 2011 Share Posted April 25, 2011 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 https://forums.phpfreaks.com/topic/234643-writing-to-google-xml-sitemap-file/ Share on other sites More sharing options...
Giddy Rob Posted April 25, 2011 Author Share Posted April 25, 2011 hmmmmm, helps if i specify the file to be saved first time done this so hey Link to comment https://forums.phpfreaks.com/topic/234643-writing-to-google-xml-sitemap-file/#findComment-1205868 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.