Re: Re: XML_Serializer - Style of empty tag

From: Date: Sat, 04 Dec 2004 21:19:19 +0000
Subject: Re: Re: XML_Serializer - Style of empty tag
References: 1 2 3 4 5 6 7 8  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-16011@lists.php.net to get a copy of this message
On Sat, 04 Dec 2004 11:16:23 +0100, Stefan Ohrmann <bshell@gmx.net> wrote: > Hello, > > Am 03.12.2004 23:33 schrieb Justin Patrin: > > > >> if ('/>' == substr($tagStr, -2)) { > >> $tagStr = str_replace(' />', '>', $tagStr); > >> $tagStr .= sprintf('</%s>', $tag['qname']); > > > > *cough* > > > > $tagStr .= '</'.$tag['qname'].'>'; > > > > Actually a better soluton woule be: > > > > if ('/>' == substr($tagStr, -2)) { > > $tagStr = substr($tagStr, 0, > > -2).'></'.$tag['qname'].'>'; > > } > > In the sprintf() use I can agree, but why the substr should be better > than the str_replace i don't understand. Also you have an extra space in > the start tag. To avoid this you have to call substr($tagStr, 0, -3). > Because it's assuming that that test is nowhere else in the tag text. This is probably true, but it's a safer solution to use substr instead. If XML_Serializer always puts a space there, then fine, it should be -3. I just don't do it when I write XML. > regards > > Stefan > -- Justin Patrin

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