Esempio n. 1
0
 public static function getXmlTree($data)
 {
     $p = xml_parser_create();
     xml_parser_set_option($p, XML_OPTION_SKIP_WHITE, 1);
     xml_parse_into_struct($p, $data, $vals, $index);
     $error = xml_get_error_code($p);
     if ($error != XML_ERROR_NONE) {
         $pieces = explode("\n", $data);
         /*
         $errorstring = xml_error_string( $error );
         $linenumber = xml_get_current_line_number( $p );
         $linetext = $pieces[xml_get_current_line_number( $p ) - 1];
         */
     }
     xml_parser_free($p);
     $tree = array();
     $i = 0;
     array_push($tree, array('tag' => $vals[$i]['tag'], 'attributes' => isset($vals[$i]['attributes']) ? $vals[$i]['attributes'] : '', 'children' => XMLParser::getChildren($vals, $i)));
     return $tree;
 }