$vals[$i]['tag'], 'attributes' => isset($vals[$i]['attributes'])? $vals[$i]['attributes'] : null, 'value' => $vals[$i]['value'], ); break; case 'open': $children[] = array( 'tag' => $vals[$i]['tag'], 'attributes' => isset($vals[$i]['attributes'])? $vals[$i]['attributes'] : null, 'children' => xml_get_children($vals, $i), ); break; case 'close': return $children; } } } function xml_get_tree($file) { $data = join('', file($file)); $parser = xml_parser_create(); xml_parser_set_option($parser, XML_OPTION_CASE_FOLDING, 0); xml_parser_set_option($parser, XML_OPTION_SKIP_WHITE, 1); xml_parse_into_struct($parser, $data, $vals, $index); xml_parser_free($parser); return array( 'tag' => $vals[0]['tag'], 'attributes' => isset($vals[0]['attributes'])? $vals[0]['attributes'] : null, 'children' => xml_get_children($vals, $i = 0) ); } function xml_condense_tree($tree) { foreach ($tree['children'] as $index => $node) { if (isset($node['children'])) { $tree['children'][$index] = xml_condense_tree($node); } elseif (isset($node['value']) and !$node['attributes']) { $tree['values'][$node['tag']] = $node['value']; unset($tree['children'][$index]); } } if (!$tree['children']) unset($tree['children']); return $tree; } function print_values($pre,$branch) { global $IDs; $var_tag = $branch['tag']; $var_value = trasformainhtml($branch['value']); $pre .= "[$var_tag]"; if( is_array($branch['attributes']) ) { foreach( $branch['attributes'] as $attr_name=>$attr_val) { if(in_array($attr_name,$IDs)) { $attr_value = trasformainhtml($attr_val); $pre.= "[\"$attr_value\"]"; } } foreach( $branch['attributes'] as $attr_name=>$attr_val) { if(!in_array($attr_name,$IDs)) { $attr_value = trasformainhtml($attr_val); echo $pre."[\"$attr_name\"]='$attr_value';\n"; } } } echo $pre."[val]='$var_value';\n"; if( $branch['children'] ) { foreach( $branch['children'] as $subbranch) { print_values($pre,$subbranch); } } } $tree = xml_get_tree($xml_filename); // $tree = xml_condense_tree($tree); echo "$attr_val) { if(!in_array($attr_name,$IDs)) { $attr_value = trasformainhtml($attr_val); echo $pre."[\"$attr_name\" ]= \"$attr_value\";\n"; // kommt das vor? } } } elseif ( $event['tag'] == "Head" ) { $eid = $event['attributes']['EvRID']; $pre = '$'."EVENTS[\"$eid\"]"; foreach($event['children'] as $subdata) { print_values($pre,$subdata); } } // print_r($event); } } echo "?>\n"; ?>