Jump to content


Photo

Beginer: use query string in a class


  • Please log in to reply
No replies to this topic

#1 stubrook

stubrook
  • New Members
  • Pip
  • Newbie
  • 1 posts

Posted 21 July 2006 - 02:21 PM

Hello,

I have the following code below and all im tyring to do is make use of a query string value inside a function in the class. The if statement im trying to use the query string value is shown below. Does anyone know how to acheive this?

Many thanks

<?php

ini_set("register_globals", "on");

class RSSParser
{
	var $insideitem = false;
	var $tag = "";
	var $title = "";
	var $body = "";

	function startElement($parser, $tagName, $attrs)
	{
		if ($this->insideitem)
		{
			$this->tag = $tagName;
		}
    		elseif ($tagName == "ITEM")
    		{
			$this->insideitem = true;
		}
	}

	function endElement($parser, $tagName)
	{
		if ($tagName == "ITEM")
		{
				printf("<b>%s</b></dt>", htmlspecialchars(trim($this->title)));
				printf("%s", htmlspecialchars(trim($this->body)));
				$this->title = "";
				$this->body = "";
				$this->insideitem = false;
		}
	}

	function characterData($parser, $data)
	{
		if ($this->insideitem)
		{

[b]		if ($lang == "en")[/b]
		{
			switch ($this->tag)
			{
				case "TITLE":
				$this->title .= $data;
				break;

				case "BODY":
				$this->body .= $data;
				break;
			}
		
		}
		}
	}
}

$xml_parser = xml_parser_create();
$rss_parser = new RSSParser();
xml_set_object($xml_parser,&$rss_parser);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");

$fp = fopen("rss.txt","r")
  or die("Error reading RSS data.");

while ($data = fread($fp, 4096))
	xml_parse($xml_parser, $data, feof($fp))
		or die(sprintf("XML error: %s at line %d", 
			xml_error_string(xml_get_error_code($xml_parser)), 
			xml_get_current_line_number($xml_parser)));
fclose($fp);

xml_parser_free($xml_parser);

?>





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users