Hi all this is my code for my main page. As you can see I try to Use the code from Class.php to go to a site and collect and display the xml data. The problem is that i can get the first part to display and not the second. The second part is from
$page="http://www.iaea.org/iaeaorg.xml";
down.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Untitled Document</title>
<link href="HomePage.css" rel="stylesheet" type="text/css" />
<style type="text/css">
<!--
#Layer1 {
position:absolute;
width:955px;
height:600px;
z-index:1;
}
#Layer2 {
position:absolute;
width:200px;
height:75px;
z-index:1;
border: 1px solid #000066;
left: 5px;
top: 5px;
}
#Layer3 {
position: absolute;
left: 210px;
width: 745px;
border: 1px solid #000066;
height: 75px;
top: 5px;
}
#Layer4 {
position: absolute;
top: 85px;
left: 5px;
border: 1px solid #000033;
width: 175px;
height: 500px;
}
#Layer5 {
position: absolute;
left: 185px;
top: 85px;
width: 554px;
border: 1px solid #000033;
height: 147px;
}
.Main-Image {
background-image: url(Images/SmallFlad.jpg);
position: relative;
height: 96px;
width: 82px;
margin-top: 5px;
margin-bottom: 5px;
margin-left: 5px;
border: 1px solid #000066;
}
.Main-Title {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
text-decoration: underline;
color: #000000;
position: absolute;
top: 5px;
left: 105px;
width: 300px;
}
.Main-Headlines {
position: absolute;
top: 25px;
left: 105px;
width: 400px;
}
.Text-Main-Headlines {
font-family: Arial, Helvetica, sans-serif;
font-size: 10px;
font-weight: bold;
text-decoration: none;
color: #000000;
list-style-type: square;
line-height: 16px;
}
#Layer6 {
left: 185px;
position: absolute;
top: 237px;
height: 147px;
width: 554px;
border: 1px solid #000033;
}
body {
margin-left: 0px;
margin-top: 0px;
margin-right: 0px;
margin-bottom: 0px;
}
.Main-Image-Europe {
background-image: url(Images/SmallEurope.jpg);
position: relative;
height: 96px;
width: 82px;
margin-top: 5px;
margin-bottom: 5px;
margin-left: 5px;
border: 1px solid #000066;
}
.Main-Title-Europe {
font-family: Arial, Helvetica, sans-serif;
font-size: 11px;
text-decoration: underline;
color: #000000;
position: absolute;
top: 5px;
left: 105px;
width: 300px;
}
.Main-Headlines-Europe {
position: absolute;
top: 25px;
left: 105px;
width: 400px;
}
-->
</style>
</head>
<body>
<div id="Layer1">
<div id="Layer2"></div>
<div id="Layer3"></div>
<div id="Layer4"></div>
<div id="Layer5">
<div class="Main-Image"></div>
<div class="Main-Headlines">
<?
include_once("/Class.php");
$page="http://www.whitehouse.gov/rss/news.xml";
$xml_parser = xml_parser_create();
$obj = new RSS();
xml_set_object($xml_parser,&$obj);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($page,"r") or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
{
if (!xml_parse($xml_parser, $data, feof($fp)))
{
$reason = xml_error_string(xml_REQUEST_error_code($xmlparser));
$reason .= xml_REQUEST_current_line_number($xmlparser);
die($reason);
}
}
fclose($fp);
xml_parser_free($xml_parser);
?>
</div>
<div class="Main-Title">Washington News - Latest WhiteHouse Headlines </div>
</div>
<div id="Layer6">
<div class="Main-Image-Europe"></div>
<div class="Main-Headlines-Europe"><?php
$page="http://www.iaea.org/iaeaorg.xml";
$xml_parser = xml_parser_create();
$obj = new RSS();
xml_set_object($xml_parser,&$obj);
xml_set_element_handler($xml_parser, "startElement", "endElement");
xml_set_character_data_handler($xml_parser, "characterData");
$fp = fopen($page,"r") or die("Error reading RSS data.");
while ($data = fread($fp, 4096))
{
if (!xml_parse($xml_parser, $data, feof($fp)))
{
$reason = xml_error_string(xml_REQUEST_error_code($xmlparser));
$reason .= xml_REQUEST_current_line_number($xmlparser);
die($reason);
}
}
fclose($fp);
xml_parser_free($xml_parser);
?></div>
<div class="Main-Title-Europe">European News - Latest European Union Headlines </div>
</div>
</div>
</body>
</html>
This is the class.php file. All i am looking to do is got to multiple rss sites and display the data on different parts of my site. Currentyl I can only get it to display the first request
<?php
class RSS
{
var $insideitem = false;
var $tag = "";
var $title = "";
var $description = "";
var $link = "";
var $date = "";
var $image = "";
function startElement($parser, $name, $attrs)
{
global $insideitem, $tag, $title, $description, $link, $date, $image;
if ($insideitem)
{
$tag = $name;
}
elseif ($name == "ITEM")
{
$insideitem = true;
}
}
function endElement($parser, $name)
{
global $insideitem, $tag, $title, $description, $link, $date, $image;
static $counter = 0;
if ($name == "ITEM" && !(++$counter > 5))
{
if ($name == "ITEM")
{
echo"<a class=Text-Main-Headlines href=$link><span class=Text-Main-Headlines>$title</span></a><br>";
$title = "";
$description = "";
$link = "";
$date = "";
$insideitem = false;
}
}
}
function characterData($parser, $data)
{
global $insideitem, $tag, $title, $description, $link, $date, $image;
if ($insideitem)
{
switch ($tag)
{
case "TITLE":
$title .= $data;
break;
case "DESCRIPTION":
$description .= $data;
break;
case "LINK":
$link .= $data;
break;
case "DATE":
$date .= $data;
break;
case "IMAGE":
$date .= $data;
break;
}
}
}
}
?>