Location: PHPKode > projects > RSS Link Adder > RSS_Reader/classes/ViewXmlFile.php
<?php
include'classes/DatabaseConnection.php';
/**
*
*
*/
class ViewXmlFile extends DatabaseConnection
{

	
	var $insideitem = false;
	var $tag = "";
	var $title = "";
	var $description = "";
	var $link = "";
	var $result;
	
/**
*to fetch url form the database
*
*/
	
	function selectUrl($sql)
		{
			$this->databaseConnectivity();
			$this->result = mysql_query($sql)or die(mysql_error());	
			//$ret = array();
			$ret = mysql_fetch_assoc($this->result)or die("could not open this page..!");
			return $ret['link_url'];
			
		}
/**
*function to handle opening tags
*
*/
	function startElement($parser, $tagName, $attrs)
		 {	 
		   			 	
			if ($this->insideitem)
			{
			$this->tag = $tagName;
			}
			elseif ($tagName == "ITEM")
			{
			$this->insideitem = true;
			}
		 }
/**
*function to handle ending tags
*
*/
	function endElement($parser, $tagName)
	    {
			
			if ($tagName == "ITEM") {
			printf("<p><b><a href='%s'>%s</a></b></p>",
			trim($this->link),htmlspecialchars(trim($this->title)));
			printf("<p>%s</p>",($this->description));
			$this->title = "";
			$this->description = "";
			$this->link = "";
			$this->insideitem = false;
			}
		}
/**
*function to handle CharacterData tags
*
*/
   function characterData($parser, $data)
   	 {
			if ($this->insideitem)
			{
			switch ($this->tag)
				{
					case "TITLE":
					$this->title .= $data;
					break;
					case "DESCRIPTION":
					$this->description .= $data;
					break;
					case "LINK":
					$this->link .= $data;
					break;
				}
			}
	}
		
}	

?> 
Return current item: RSS Link Adder