I have a XML file i want to stream to my website. Its at
I have a problem because my html output from the parser has:
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
included as text before my descriptions. I noticed the xml has a [CDATA]. Basically i cannot figure out a way to incorporate this extra code or get rid of it. I've tried both outs.
Please set me free !! here is all my info:
THE SCRIPT:
<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s'>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dd>%s</dd>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen(" 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);
?>
The XML file is at
Here the output I'm getting:
World Series of Poker Changes Payout Structures
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">World Series of Poker officials said Tuesday that the payout schedules for the 2007 World Series ...
Press Release: eCOGRA Offers Online Gambling Fairness Testing
<p><city><place>LONDON</place></city> -- 130 Leading Casino and Poker Brands to Display eCOGRA's Software Fairness Reports <p /></p><p>The online ...
World Poker Tour Releases Season Six Schedule
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">The first tournament of the Mirage Poker Showdown began Tuesday, and with that, so did the sixth ...
World Series of Poker Issues Scam Warning
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Harrah's Entertainment and the World Series of Poker quietly issued a warning a couple weeks ago ...
J.C. Tran Named WPT Player of the Year
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Even though the top spot in the World Poker Tour Player of the Year race could have changed hands ...
notice the ugly stuff.
THanks in advance
Mike
I have a problem because my html output from the parser has:
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">
included as text before my descriptions. I noticed the xml has a [CDATA]. Basically i cannot figure out a way to incorporate this extra code or get rid of it. I've tried both outs.
Please set me free !! here is all my info:
THE SCRIPT:
<?php
$insideitem = false;
$tag = "";
$title = "";
$description = "";
$link = "";
function startElement($parser, $name, $attrs) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
$tag = $name;
} elseif ($name == "ITEM") {
$insideitem = true;
}
}
function endElement($parser, $name) {
global $insideitem, $tag, $title, $description, $link;
if ($name == "ITEM") {
printf("<dt><b><a href='%s'>%s</a></b></dt>",
trim($link),htmlspecialchars(trim($title)));
printf("<dd>%s</dd>",htmlspecialchars(trim($description)));
$title = "";
$description = "";
$link = "";
$insideitem = false;
}
}
function characterData($parser, $data) {
global $insideitem, $tag, $title, $description, $link;
if ($insideitem) {
switch ($tag) {
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
}
}
}
$xml_parser = xml_parser_create();
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen(" 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);
?>
The XML file is at
Here the output I'm getting:
World Series of Poker Changes Payout Structures
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">World Series of Poker officials said Tuesday that the payout schedules for the 2007 World Series ...
Press Release: eCOGRA Offers Online Gambling Fairness Testing
<p><city><place>LONDON</place></city> -- 130 Leading Casino and Poker Brands to Display eCOGRA's Software Fairness Reports <p /></p><p>The online ...
World Poker Tour Releases Season Six Schedule
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">The first tournament of the Mirage Poker Showdown began Tuesday, and with that, so did the sixth ...
World Series of Poker Issues Scam Warning
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Harrah's Entertainment and the World Series of Poker quietly issued a warning a couple weeks ago ...
J.C. Tran Named WPT Player of the Year
<p class="MsoNormal" style="MARGIN: 0in 0in 0pt">Even though the top spot in the World Poker Tour Player of the Year race could have changed hands ...
notice the ugly stuff.
THanks in advance
Mike