Jump to content

Archived

This topic is now archived and is closed to further replies.

stubrook

Beginer: use query string in a class

Recommended Posts

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

[code]
<?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);

?>
[/code]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.