note 85948 added to function.xml-parse-into-struct

From: Date: Thu, 25 Sep 2008 23:16:59 +0000
Subject: note 85948 added to function.xml-parse-into-struct
Groups: php.notes 
Request: Send a blank email to php-notes+get-144717@lists.php.net to get a copy of this message
here you can [re]assemble xml from a xml_parse_into_struct generated array: ie array2xml $xml_parser = xml_parser_create( 'UTF-8' ); // UTF-8 or ISO-8859-1 xml_parser_set_option( $xml_parser, XML_OPTION_CASE_FOLDING, 0 ); xml_parser_set_option( $xml_parser, XML_OPTION_SKIP_WHITE, 1 ); xml_parse_into_struct( $xml_parser, $my_text_xml, $aryXML ); xml_parser_free($xml_parser); //now use aryXML array to xml string: $o=''; foreach( $aryXML as $tag ){ //tab space: for($i=1; $i < $tag['level'];$i++) $o.="\t"; if($tag['type']!='close'){ if($tag['type']!='cdata') $o.='<'.$tag['tag']; if(isset($tag['attributes'])){ foreach($tag['attributes'] as $attr=>$aval){ $o.=' '.$attr.'="'.$aval.'"'; } } if($tag['type']!='cdata'){ $o.=($tag['type']=='complete')?'/>'."\n":'>'."\n"; } $o.=(isset($tag['value']))?$tag['value']:''; }else{ $o.='</'.$tag['tag'].'>'; } } ---- Server IP: 208.69.120.35 Probable Submitter: 69.17.48.227 ---- Manual Page -- http://www.php.net/manual/en/function.xml-parse-into-struct.php Edit -- https://master.php.net/note/edit/85948 Del: integrated -- https://master.php.net/note/delete/85948/integrated Del: useless -- https://master.php.net/note/delete/85948/useless Del: bad code -- https://master.php.net/note/delete/85948/bad+code Del: spam -- https://master.php.net/note/delete/85948/spam Del: non-english -- https://master.php.net/note/delete/85948/non-english Del: in docs -- https://master.php.net/note/delete/85948/in+docs Del: other reasons-- https://master.php.net/note/delete/85948 Reject -- https://master.php.net/note/reject/85948 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#144717) next »