dezkit Posted May 21, 2010 Share Posted May 21, 2010 hey guys i got this code: <?php $file = "http://steamcommunity.com/id/itzdezkit/?xml=1"; function contents($parser, $data){ echo $data; } function startTag($parser, $data){ echo "<b>"; } function endTag($parser, $data){ echo "</b><br />"; } $xml_parser = xml_parser_create(); xml_set_element_handler($xml_parser, "steamID", "steamID"); xml_set_character_data_handler($xml_parser, "contents"); $fp = fopen($file, "r"); $data = fread($fp, 80000); if(!(xml_parse($xml_parser, $data, feof($fp)))){ die("Error on line " . xml_get_current_line_number($xml_parser)); } xml_parser_free($xml_parser); fclose($fp); ?> which doesn't work and gives me this error: Warning: xml_parse() [function.xml-parse]: Unable to call handler steamID() in /home/dima1989/public_html/testz.php on line 28 what im trying to do: get all the inforamtion between <steamID> and </steamID> how would i be able to fix this? thank you. also i would like to set the parsed infrmation into a variable. Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted May 21, 2010 Share Posted May 21, 2010 This is the definition of the function you are using - bool xml_set_element_handler ( resource $parser , callback $start_element_handler , callback $end_element_handler ) This is your usage of it - xml_set_element_handler($xml_parser, "steamID", "steamID"); Did you put your start and end element handlers in as the second and third parameters? i would like to set the parsed information into a variable Because the callback functions are called by the parser and cannot return values to your program, you would need to use this inside of a class/OOP where you can set class variables inside of the callback functions in order to make the parsed information available to other code in your program. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.