All pastes #980799 Raw Edit

Miscellany

public php v1 · immutable
·published 2008-04-11 08:40 UTC
rendered paste body
<?phpfunction prn($array){	foreach($array as $element)	{				if(!strcmp($element['tag'],"DIRECTORY") && is_array($element['attributes']))		{			$tmp = $element['attributes']['NAME'];			$location[$element['level']] = $tmp;		}		elseif(!strcmp($element['tag'],"FILE"))		{			for($x=1; $x<sizeof($location)+1; $x++)			{				echo "/".$location[$x];			}			echo "/".$element['attributes']['NAME']."\n";		}	}}//xml file to parse$xmlfile = 'small_files.xml';$xmlparser = xml_parser_create();// open a file and read data$fp = fopen($xmlfile, 'r');$xmldata = fread($fp, 4096);xml_parse_into_struct($xmlparser,$xmldata,$values);xml_parser_free($xmlparser);prn($values);?>