Re: Re: XML_Serializer - Style of empty tag
| From: | Justin Patrin | Date: | Fri, 03 Dec 2004 22:33:14 +0000 |
| Subject: | Re: Re: XML_Serializer - Style of empty tag | ||
| References: | 1 2 3 4 5 6 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15997@lists.php.net to get a copy of this message | ||
On Fri, 03 Dec 2004 20:38:31 +0100, Stefan Ohrmann <bshell@gmx.net> wrote:
> Hello,
>
> Am 01.12.2004 11:53 schrieb Georg Bez:
>
> > Yes, You are right completely and it puts me also before no bigger
> > problems :-) to build an appropriate regex.
>
> You don't need a regex, only a little bit of object orientation.
>
> > My wish would be to be had this option directly in XML_Serializer. I
> > hope this is not to be measured.
> > If Stephan informs me that he does not find this meaningfully, no time
> > or desire has ;-) has then do I the other variant. However, till there I
> > still have hope.
>
> Try following, but you have to change your application in the way of
> getting the instances.
>
> <?php
> /**
> * XML_Serializer_Unfolder
> */
> require_once 'XML/Serializer.php';
>
> class XML_Serializer_Unfolder extends XML_Serializer
> {
> function _createXMLTag($tag, $replaceEntities = true)
> {
> $tagStr = parent::_createXMLTag($tag, $replaceEntities);
>
> 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'].'>';
}
> }
> return $tagStr;
> }
> }
> ?>
>
> But be aware, that I didn't do a full unit test for this solution.
>
--
Justin Patrin