Re: XML_FastCreate child appending

From: Date: Wed, 07 Jul 2004 10:16:44 +0000
Subject: Re: XML_FastCreate child appending
References: 1 2 3 4 5  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-13518@lists.php.net to get a copy of this message
Le mer 07/07/2004 à 12:01, Sönke Ruempler a écrit : > Hi and thx for your help, > > > > In the case that i open a tag but i don't know which and how many childs > > > follow, i was looking for a method to add the childs dynamicly, not in > one > > > step. > > > > > > With you second example there is the problem again that i can add one > child > > > but then cannot append more childs to the div tag, right? > > Yes, you must construct $blah before, and call the $x->div($blah) after. > > Here a simple example: > > $xml .= '<div>'; > $xml .= '<span>blah</span>'; > > if ($blah == $blub) { > $xml .= '<span>blub</span>'; > } > > $xml .= '<ul>'; > > for ($i = 0; $i < 5; $i++) { > $xml .= '<li>' . $i . '</li>'; > } > > $xml .= '</ul>'; > $xml .= '</div>'; > > Can i do that with XML_FastCreate? ;-) You can do this : $xml = $x->span("blah"); if ($blah == $blub) { $xml .= $x->span("blub"); } $ul = ''; for ($i=0; $i < 5; $i++) { $ul .= $x->li($i); } $xml = $x->div( $x->ul($ul) ); See also the importXML() / exportXML() functions : http://pear.php.net/package/XML_FastCreate/docs/0.9/apidoc/XML_FastCreate-0.9/XML_FastCreate.html Regards,

« previous php.pear.general (#13518) next »