XML : PHP ROORO Premature end of data in tag list

The following is my parsing file, but it keep saying that

Warning: simplexml_load_file(): svn_list.xml:5: parser error : Premature end of data in tag list line 3 in /Users/yuki/PhpstormProjects/untitled2/parser.php on line 7 Warning: simplexml_load_file(): in /Users/yuki/PhpstormProjects/untitled2/parser.php on line 7 Warning: simplexml_load_file(): ^ in /Users/yuki/PhpstormProjects/untitled2/parser.php on line 7 Warning: simplexml_load_file(): svn_list.xml:5: parser error : Premature end of data in tag lists line 2 in /Users/yuki/PhpstormProjects/untitled2/parser.php on line 7 Warning: simplexml_load_file(): in /Users/yuki/PhpstormProjects/untitled2/parser.php on line 7 Warning: simplexml_load_file(): ^ in /Users/yuki/PhpstormProjects/untitled2/parser.php on line 7

  <?php    class Parser  {        function parse_list($name)      {          $xml = simplexml_load_file("svn_list.xml") or die("Error: Cannot create object");          $list = array();          $json = json_decode(json_encode($xml), TRUE);          $count = count($json["list"]["entry"]);          for ($i = 0; $i < $count; $i++) {              $size = '';              $path = $json["list"]["entry"][$i]["name"];              // if not directory, it must have a size              if ($json["list"]["entry"][$i]["@attributes"]["kind"] != "dir") {                  $size = $json["list"]["entry"][$i]["size"];              }              if (substr($path, 0, strlen($name)) == $name) {                  $type = $json["list"]["entry"][$i]["@attributes"]["kind"];                  $rev = $json["list"]["entry"][$i]["commit"]["@attributes"]["revision"];                  $auth = $json["list"]["entry"][$i]["commit"]["author"];                  $date = $json["list"]["entry"][$i]["commit"]["date"];                  array_push($list, array($path, $size, $type, $rev, $auth, $date));              }          }          return $list;      }        function parse_log($name)      {          $xml = simplexml_load_file("svn_log.xml") or die("Error: Cannot create object");          $log = array();          $json = json_decode(json_encode($xml), TRUE);          $count = count($json["logentry"]);          for ($i = 0; $i < $count; $i++) {              $paths_count = count($json["logentry"][$i]["paths"]["path"]);              for ($j = 0; $j < $paths_count; $j++) {                  $path_name = $json["logentry"][$i]["paths"]["path"][$j];                  if (substr($path_name,7,strlen($name)) == $name) {                      $curr_rev = $json["logentry"][$i]["@attributes"]["revision"];                      $curr_act = $json["logentry"][$i]["paths"]["path"]["action"];                      $curr_msg = $json["logentry"][$i]["msg"];                      array_push($log, array($curr_rev, $curr_msg,$curr_act));                      break;                  }              }          }          return $log;      }  }    

No comments:

Post a Comment