PHP 5 simplexml incompatability?
Posted: Mon Jun 11, 2007 1:49 pm
I have the following code working PERFECTLY in PHP 5.2.0 but get errors when dealing with the child elements for "media" and "bc" in PHP 5.1.4.
Here's the error:
Code: Select all
$rss = simplexml_load_file('http://link.brightcove.com/services/link/bcpid960594405?action=mrss&v=2');
$a = 1; //set beginning of increment
foreach($rss->channel->item as $item) {
echo '<p>',$a,' - title: ', $item->title, "<br />\n";
echo 'link: ', $item->link, "<br />\n";
echo 'description: ', $item->description, "<br />\n";
echo 'pubDate: ', $item->pubDate, "<br />\n";
$e = 0; //set beginning of increment
foreach($item->children('media', true) as $media) {
foreach ($media->attributes() as $key => $value) {
echo $media->getName(), " {$key}: {$value}<br>";
$value2[$e] = $value;
echo "$value2[$e]<br>";
$e++;
}
}
$i = 0; //set beginning of increment
foreach($item->children('bc', true) as $bc) {
//echo 'bc: ', $bc->getName(), ": ",$bc, "<br />\n";
//assign unique array variables via loop
$bc2[$i] = $bc;
echo "$bc2[$i]<br>";
$i++;
}
}Here's the error:
Is this simply an incompatibility with the versions or does anyone have an idea as to tweaking the code to make it friendly for both? Thanks in advance!
Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /home/content/f/a/f/faftp/html/video/import.php on line 16
Warning: Invalid argument supplied for foreach() in /home/content/f/a/f/faftp/html/video/import.php on line 16
Warning: SimpleXMLElement::children() expects at most 1 parameter, 2 given in /home/content/f/a/t/faftp/html/video/import.php on line 32
Warning: Invalid argument supplied for foreach() in /home/content/f/a/f/faftp/html/video/import.php on line 32