Re: Re: XML_Serializer - Style of empty tag
| From: | Stefan Ohrmann | Date: | Fri, 03 Dec 2004 19:38:31 +0000 |
| Subject: | Re: Re: XML_Serializer - Style of empty tag | ||
| References: | 1 2 3 4 5 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15996@lists.php.net to get a copy of this message | ||
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']);
}
return $tagStr;
}
}
?>
But be aware, that I didn't do a full unit test for this solution.
regards
Stefan