Ive never used XML before. I have a few things to ask that I'm having troubles with:
This page works except that it contains data from element tags that I wish to ignore how do I ignore them? http://godofgod.co.uk/videos/view_video.php?id=35 I only want to use author and title. EDIT: Now I'm tring to fix this with <!-- and -->
On the same page how can I ignore the first author and title tags as this is a pointless comment that I do not need.
On one particular page I get:
phpBB Debug] PHP Notice: in file /home/godofgod/public_html/videos/view_video.php on line 817: fopen(http://gdata.youtube.com/feeds/videos/aFczqbcqYnI/comments): failed to open stream: HTTP request failed! HTTP/1.0 404 Not Found
[phpBB Debug] PHP Notice: in file /home/godofgod/public_html/videos/view_video.php on line 818: fread(): supplied argument is not a valid stream resource
I'm guessing it's tring to say it can't open the file but why? The file is there.
Thanks
In case you need the code it's below:
//insert youtube comments
$file = 'http://gdata.youtube.com/feeds/videos/' . $url . '/comments';
$parser=xml_parser_create();
//Function to use at the start of an element
function start($parser,$element_name,$element_attrs)
{
switch($element_name)
{
case "NAME":
echo "<p><b>";
break;
}
}
//Function to use at the end of an element
function stop($parser,$element_name)
{
switch($element_name)
{
case "NAME":
echo "</b></p><br><HR><br>";
break;
}
}
//Function to use when finding character data
function char($parser,$data)
{
echo $data;
}
//Specify element handler
xml_set_element_handler($parser,"start","stop");//Specify data handler
xml_set_character_data_handler($parser,"char");//Open XML file
$fp=fopen($file,"r");//Read data
while ($data=fread($fp,4096))
{
xml_parse($parser,$data,feof($fp)) or
die (sprintf("XML Error: %s at line %d",
xml_error_string(xml_get_error_code($parser)),
xml_get_current_line_number($parser)));
}
//Free the XML parser
xml_parser_free($parser);
}