Hi,
I've written a piece of code for finding out what version of RSS a stream is using:
Code:
// Gets the attributes of the rss tag
function startElement( $parser, $name, $attrs )
{
global $currentElements, $feedCount, $classArray;
if( $name == "rss" )
{
$feedCount += 1;
if (sizeof($attrs))
{
// Enter any attributes of rss tag into the array
while (list($k, $v) = each($attrs))
{
$classArray[rss_version][$k] = $v;
}
}
}
}
Works fine and puts the output into an array e.g.:
$classArray[rss_version][version] = 2;
. excuse the unusual placements of the braces, it's the standard for my CMS.
The Problem
When I add some more code, which I wrote seperately and also works, I can't seem to get the two to work in union:
Code:
function startElement( $parser, $name, $itemCount )
{
global $currentElements, $feedCount, $itemCount, $classArray;
// Gets the attributes of the rss tag
if( $name == "rss" )
{
$feedCount += 1;
if (sizeof($attrs))
{
// Enter any attributes of rss tag into the array
while (list($k, $v) = each($attrs))
{
$classArray[rss_version][$k] = $v;
}
}
else
{
echo "Unable to identify the class of object to be created\n";
}
}
if ( ( $name == 'summary' ) or ( $name == 'body' ) )
{
push( $currentElements, $name );
}
else
{
array_push( $currentElements, $name );
}
if( $name == "item" )
{
$itemCount += 1;
}
}
No errors, but from inserting echo's in various place I can tell that "if (sizeof($attrs))" returns false in this situation and I don't know why! Can anyone shed any light? Let me know if you need more code to help me figure it out.
Regards,
James