From 866c47ec603595e8fe67da5f0e5d162a70b1f7b4 Mon Sep 17 00:00:00 2001 From: cookie Date: Sun, 6 Nov 2005 17:14:25 +0000 Subject: move files git-svn-id: svn://svn.cccv.de/engel-system@20 29ba0400-6e00-0410-a75a-ca02368028f8 --- www-ssl/inc/funktion_xml.php | 140 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 140 insertions(+) create mode 100755 www-ssl/inc/funktion_xml.php (limited to 'www-ssl/inc/funktion_xml.php') diff --git a/www-ssl/inc/funktion_xml.php b/www-ssl/inc/funktion_xml.php new file mode 100755 index 00000000..41a18503 --- /dev/null +++ b/www-ssl/inc/funktion_xml.php @@ -0,0 +1,140 @@ +sub[ $XMLpos[$Tiefe] ]->data .= convertValues($Data); + if( $XMLDEBUG) + echo "???". $Objekt->sub[ $XMLpos[$Tiefe] ]->name. "|$Data|$Tiefe???
"; + } + else + dataXMLmain( $Data, $Objekt->sub[ $XMLpos[$Tiefe] ], $Tiefe+1); +} + +function startXMLmain( $Data, &$Objekt, $Tiefe ) +{ + global $XMLpos, $depth, $XMLDEBUG; + + if( $XMLDEBUG) + if($Tiefe==1) + { print_r(array_values ($XMLpos)); echo "--".$Data->name; + echo " #$Tiefe/$depth#"; + } + + if( $depth==$Tiefe) + { + $Objekt->sub[ $XMLpos[$Tiefe] ] = $Data; + if( $XMLDEBUG) + echo "|". $XMLpos[$Tiefe]."|". $Objekt->sub[ $XMLpos[$Tiefe] ]->name. " ". $Data->name." save|". "#-#
"; + } + else + startXMLmain( $Data, $Objekt->sub[ $XMLpos[$Tiefe] ], $Tiefe+1); +} + +function start_element_handler($parser, $name, $attribs) +{ + global $depth, $XMLmain, $XMLpos; + + $Data = new element; + $Data->name = $name; + while(list($key, $value) = each($attribs)) + $Data->attributes[$key] = convertValues($value); + $Data->depth = $depth; + $XMLpos[$depth]++; + + if( $depth==0) + $XMLmain= $Data; + else + startXMLmain( $Data, $XMLmain, 1); + + $depth++; +} + +function end_element_handler($parser, $name) +{ + global $depth, $XMLpos; + $XMLpos[$depth]=0; + $depth--; +} + +function character_data_handler($parser, $data) +{ + global $XMLmain; + if( strlen(trim($data)) ) + dataXMLmain( $data, $XMLmain, 1); +} + +/*#######################################################################################*/ +function readXMLfile( $file ) +{ + //$xml_parser = xml_parser_create_ns(); + $xml_parser = xml_parser_create("UTF-8"); + xml_set_element_handler($xml_parser, "start_element_handler", "end_element_handler"); + xml_set_character_data_handler($xml_parser, "character_data_handler"); + if (!($fp = fopen($file, "r"))) + { + echo("

could not open XML file \"$file\"

"); + return -1; + } + + if( $XMLDEBUG) echo "
";
+	while ($data = fread($fp, 4096)) 
+	{
+		if (!xml_parse($xml_parser, $data, feof($fp))) 
+		{
+			die(sprintf("XML error: %s at line %d",
+				    xml_error_string(xml_get_error_code($xml_parser)),
+				    xml_get_current_line_number($xml_parser)));
+		}
+	}
+	if( $XMLDEBUG)	echo "
"; + xml_parser_free($xml_parser); + return 0; +} + +/*#######################################################################################*/ +function getXMLsubPease( $Sourse, $Name ) +{ + while(list($key, $value) = each($Sourse->sub)) + if( $value->name == $Name) + return $value; + + echo "

Fehler: getXMLsubPease( $Sourse, $Name ) not found

"; +// die; +} + +?> -- cgit v1.2.3-54-g00ecf