resParser = xml_parser_create ('utf-8'); xml_set_object($this->resParser,$this); xml_set_element_handler($this->resParser, "tagOpen", "tagClosed"); xml_set_character_data_handler($this->resParser, "tagData"); $this->strXmlData = xml_parse($this->resParser,$strInputXML ); if(!$this->strXmlData) { die(sprintf("XML error: %s at line %d", xml_error_string(xml_get_error_code($this->resParser)), xml_get_current_line_number($this->resParser))); } xml_parser_free($this->resParser); return $this->arrOutput; } function tagOpen($parser, $name, $attrs) { $tag=array("name"=>$name,"attrs"=>$attrs); array_push($this->arrOutput,$tag); } function tagData($parser, $tagData) { if(trim($tagData)) { if(isset($this->arrOutput[count($this->arrOutput)-1]['tagData'])) { $this->arrOutput[count($this->arrOutput)-1]['tagData'] .= $tagData; } else { $this->arrOutput[count($this->arrOutput)-1]['tagData'] = $tagData; } } } function tagClosed($parser, $name) { $this->arrOutput[count($this->arrOutput)-2]['children'][] = $this->arrOutput[count($this->arrOutput)-1]; array_pop($this->arrOutput); } } //This is where stuff happens $objXML = new xml2Array(); $feed = $objXML->parse(file_get_contents($sc2pod_blue_filename)); $feed = $feed[0]['children'][0]['children']; $sc2pod_blue = Array(); $i = 0; foreach ($feed as &$v) { if(strtolower($v['name']) == 'item') { foreach ($v['children'] as &$h) { $name = strtolower($h['name']); if($name == 'title') { $i++; $sc2pod_blue[$i]['title'] = $h['tagData']; } elseif($name == 'link') $sc2pod_blue[$i]['url'] = $h['tagData']; elseif($name == 'description') $sc2pod_blue[$i]['description'] =$h['tagData']; elseif($name == 'pubdate') $sc2pod_blue[$i]['date'] = $h['tagData']; elseif($name == 'author') $sc2pod_blue[$i]['author'] = $h['tagData']; } } } //echo '
';
//print_r($sc2pod_blue);

?>