mattd8752 Posted March 10, 2007 Share Posted March 10, 2007 For some reason, this script isn't fully running through. It is outputting 1<main> When it should also print_r an array. Heres the code, if anyone could find my problem, it would be appreciated. <?php class xmlread { function input($cont){ $this->data = $cont; } function read($main){ $data = $this->data; $line = 0; $level = 0; $tag = 0; while($line < sizeof($data)){ $inxml = FALSE; if($inxml == FALSE){ if(trim($data[$line]) == "<".trim($main).">"){ $inxml == TRUE; $level = 1; echo "1"; echo $data[$line]; } }else{ if($level == 1){ echo "2"; if(ereg("^<", trim($data[$line])) && ereg(">$", trim($data[line])) && !ereg("^</", trim($data[$line]))){ $tag = explode("<", $data[$line]); $tag = explode(">", $tag[1]); $tag = $tag[0]; $level = 2; }elseif("<".$main.">" == trim($data[$line])){ echo "3"; $inxml = FALSE; } }elseif($level == 2){ if(ereg("^</", trim($data[$line])) && ereg(">$", trim($data[$line]))){ $level = 1; $tag = 0; }else{ $tagb = explode("<", $data[$line], 1); $tagb = explode(">", $tagb[1], 1); $tagc = $tagb[0]; $tagb = explode("<", $tagb[1], 1); $fill = $tagb[0]; $tagb = explode(">", $tagb[1], 1); if($tagb[0] != $tagc){ die("Error: XML"); }else{ $return[$tag][$tagc] = $fill; } } } } $line++; } return $return; } } $test = new xmlread; $page = file('test.xml'); $test->input($page); print_r($test->read('main')); ?> Link to comment https://forums.phpfreaks.com/topic/42143-broken-xml-reader-script/ Share on other sites More sharing options...
mattd8752 Posted March 10, 2007 Author Share Posted March 10, 2007 Bump Link to comment https://forums.phpfreaks.com/topic/42143-broken-xml-reader-script/#findComment-204463 Share on other sites More sharing options...
mattd8752 Posted March 10, 2007 Author Share Posted March 10, 2007 Bump Link to comment https://forums.phpfreaks.com/topic/42143-broken-xml-reader-script/#findComment-204485 Share on other sites More sharing options...
mattd8752 Posted March 11, 2007 Author Share Posted March 11, 2007 Bump Link to comment https://forums.phpfreaks.com/topic/42143-broken-xml-reader-script/#findComment-204749 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.