blesseld Posted April 15, 2010 Share Posted April 15, 2010 Hey All, I have recently been developing a template with a built in WYSIWYG editor and it saves data to a file using fopen. I also setup a separate form that saves meta data to a file. There is no database at all. I tried looking all over, but everything is based on MySQL. I am looking for a way to generate a sitemap for the pages the user chooses. so if the user has a 5 page website, they would open the edit page for lets say index.php I would have a separate form for the Sitemap info. that will save to a file. I am curious how I can create a script that will open the Sitemap info files and generate a sitemap. End result can either create a sitemap file and save it to the root, or output the xml code that the user can copy and paste into their sitemap.xml file Thanks in advance. Carlo Quote Link to comment https://forums.phpfreaks.com/topic/198675-how-can-i-create-xml-sitemap-no-database-involved/ Share on other sites More sharing options...
ignace Posted April 15, 2010 Share Posted April 15, 2010 Signup for Google Webmaster it allows you to create a XML sitemap using the sitemap protocol. Quote Link to comment https://forums.phpfreaks.com/topic/198675-how-can-i-create-xml-sitemap-no-database-involved/#findComment-1042687 Share on other sites More sharing options...
blesseld Posted April 15, 2010 Author Share Posted April 15, 2010 Thanks, but no thanks... i am aware of webmaster tools... Not looking for alternate solutions. looking for a solution to my problem. I am marketing to a particular group. Quote Link to comment https://forums.phpfreaks.com/topic/198675-how-can-i-create-xml-sitemap-no-database-involved/#findComment-1042722 Share on other sites More sharing options...
ignace Posted April 16, 2010 Share Posted April 16, 2010 Have you tried DomDocument? Quote Link to comment https://forums.phpfreaks.com/topic/198675-how-can-i-create-xml-sitemap-no-database-involved/#findComment-1042999 Share on other sites More sharing options...
blesseld Posted April 19, 2010 Author Share Posted April 19, 2010 After a bit of searching I found this: <?php // Simon Willison, 16th April 2003 // Based on Lars Marius Garshol's Python XMLWriter class // See http://www.xml.com/pub/a/2003/04/09/py-xml.html class XmlWriter { var $xml; var $indent; var $stack = array(); function XmlWriter($indent = ' ') { $this->indent = $indent; $this->xml = '<?xml version="1.0" encoding="utf-8"?>'."\n"; } function _indent() { for ($i = 0, $j = count($this->stack); $i < $j; $i++) { $this->xml .= $this->indent; } } function push($element, $attributes = array()) { $this->_indent(); $this->xml .= '<'.$element; foreach ($attributes as $key => $value) { $this->xml .= ' '.$key.'="'.htmlentities($value).'"'; } $this->xml .= ">\n"; $this->stack[] = $element; } function element($element, $content, $attributes = array()) { $this->_indent(); $this->xml .= '<'.$element; foreach ($attributes as $key => $value) { $this->xml .= ' '.$key.'="'.htmlentities($value).'"'; } $this->xml .= '>'.htmlentities($content).'</'.$element.'>'."\n"; } function emptyelement($element, $attributes = array()) { $this->_indent(); $this->xml .= '<'.$element; foreach ($attributes as $key => $value) { $this->xml .= ' '.$key.'="'.htmlentities($value).'"'; } $this->xml .= " />\n"; } function pop() { $element = array_pop($this->stack); $this->_indent(); $this->xml .= "</$element>\n"; } function getXml() { return $this->xml; } } /* Test $xml = new XmlWriter(); $array = array( array('monkey', 'banana', 'Jim'), array('hamster', 'apples', 'Kola'), array('turtle', 'beans', 'Berty'), ); $xml->push('zoo'); foreach ($array as $animal) { $xml->push('animal', array('species' => $animal[0])); $xml->element('name', $animal[2]); $xml->element('food', $animal[1]); $xml->pop(); } $xml->pop(); print $xml->getXml(); */ ?> havn't had a chance to play with it yet though. Quote Link to comment https://forums.phpfreaks.com/topic/198675-how-can-i-create-xml-sitemap-no-database-involved/#findComment-1044736 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.