indent = $indent; $this->xml = ''.''; } 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 .= ">"; $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).''.""; } function emptyelement($element, $attributes = array()) { $this->_indent(); $this->xml .= '<'.$element; foreach ($attributes as $key => $value) { $this->xml .= ' '.$key.'="'.htmlentities($value).'"'; } $this->xml .= " />"; } function pop() { $element = array_pop($this->stack); $this->_indent(); $this->xml .= ""; } function getXml() { return $this->xml.""; } } require_once ("system/include/conf.php"); $query = "SELECT id,date,title,body FROM ".$dbprefix."_news ORDER BY date DESC"; $result = mysql_query($query); $num = mysql_num_rows($result); if ($num) { $xml = new XmlWriter(); $xml->push('channel'); $xml->element('title', 'ListBargains.com Site News'); $xml->element('link', 'http://www.listbargains.com/news.php'); $xml->element('description', 'ListBargains.com new products, datacards, and website news.'); $xml->element('language', 'en-us'); while ($data = mysql_fetch_array($result)) { $id = $data['id']; $title = stripslashes(urldecode($data['title'])); $description = stripslashes(urldecode($data['body'])); $description = str_replace("…", "...", $description); $xml->push('item'); $xml->element('title', $title); $xml->element('link', 'http://www.listbargains.com/news.php?id='.$id.''); $xml->element('description', $description); $xml->pop(); } $xml->pop(); print $xml->getXml(); } ?>