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

From: Date: Fri, 28 Nov 2008 23:55:35 +0000
Subject: note 87304 added to function.xml-parse-into-struct
Groups: php.notes 
Request: Send a blank email to php-notes+get-147404@lists.php.net to get a copy of this message
Here's another attempt at dealing with rebuilding the xml from the array. I'm basically preventing certain tags from being self closing by just checking for them explicitly (sure wish expat didn't interpret <textarea /> and <textarea></textarea> the same way (as "complete" tags). <? function array2xml($xmlary){ $o=''; foreach($xmlary as $tag ){ if($tag['tag'] == 'textarea' && !isset($tag['value'])){ //fake a value so it won't self close $tag['value']=''; } //tab space: $t = ''; for($i=1; $i < $tag['level'];$i++){ $t.="\t"; } switch($tag['type']){ case 'complete': case 'open': $o.=$t.'<'.$tag['tag']; if(isset($tag['attributes'])){ foreach($tag['attributes'] as $attr=>$aval){ $o.=' '.$attr.'="'.$aval.'"'; }//foreach }//attributes if($tag['type'] == 'complete'){ if(!isset($tag['value'])){ $o .= ' />'."\n"; } else { $o .= '>'."\n".$t.$tag['value']."\n".$t.'</'.$tag['tag'].'>'."\n"; } }else{ $o .= '>'."\n"; } break; case 'close': $o .= $t.'</'.$tag['tag'].'>'."\n"; break; case 'cdata': $o .= $t.$tag['value']."\n"; break; }//switch }//foreach } ?> ---- Server IP: 208.69.120.35 Probable Submitter: 70.193.136.17 ---- Manual Page -- http://www.php.net/manual/en/function.xml-parse-into-struct.php Edit -- https://master.php.net/note/edit/87304 Del: integrated -- https://master.php.net/note/delete/87304/integrated Del: useless -- https://master.php.net/note/delete/87304/useless Del: bad code -- https://master.php.net/note/delete/87304/bad+code Del: spam -- https://master.php.net/note/delete/87304/spam Del: non-english -- https://master.php.net/note/delete/87304/non-english Del: in docs -- https://master.php.net/note/delete/87304/in+docs Del: other reasons-- https://master.php.net/note/delete/87304 Reject -- https://master.php.net/note/reject/87304 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#147404) next »