Hey,

Yea, I thought this will have similarity but yea there is no need to add
another component if there is already one that does it. Although i
personally use this in my projects, There is no need for duplicating
functionality. I guess this can be archived. :)

Thanks for taking a look at it.

Vince.

On Fri, Apr 24, 2009 at 7:33 PM, Matthew Weier O'Phinney
<[email protected]>wrote:

> -- Vadim Gabriel <[email protected]> wrote
> (on Friday, 24 April 2009, 06:25 PM +0300):
> > I was wondering if anyone willing to give some feedback about the
> proposal i
> > made @link http://framework.zend.com/wiki/display/ZFPROP/
> > Zend_Xml+-+Vadim+Gabriel
> >
> > I am not sure how often this is used by other developers but i use this
> very
> > often. I am also not sure if this is something that was already made or
> talked
> > about, I couldn't find anything about it.
>
> You may want to see how Zend_Config_Xml and Zend_Config_Writer_Xml work,
> as they already do much of this. As an example:
>
>    $xml =<<<EOX
>    <?xml version="1.0"?>
>    <foo>
>        <bar>Bar</bar>
>        <baz>
>            <foo>Foo</foo>
>            <bar>Bar</bar>
>        </baz>
>    </foo>
>    EOX;
>    $config = new Zend_Config_Xml($xml);
>    $arr = $config->toArray();
>    echo var_export($arr, 1), "\n";
>
>    $writer = new Zend_Config_Writer_Xml();
>    $writer->setFilename('php://stdout')
>        ->setConfig($config);
>    ob_start();
>    $writer->write();
>    $genXml = ob_get_clean();
>    echo var_export($genXml, 1), "\n";
>
> It's not flawless, but if you run the above, you'll see that the first
> instance transforms the XML to an array, the second transforms a config
> to XML. (You can transform an array to a config object by simply doing
> $config = new Zend_Config($array); ) It may be useful to add a method to
> the Zend_Config_Writer base class to allow retrieving the generated text
> (instead of writing it directly to file) -- this would obviate the need
> to do the output buffering hack above.
>
> Otherwise, it kinda makes sense -- casting a SimpleXML object to an
> array is non-recursive, and there are no native PHP libraries for
> casting an array to an XML document. However, if what you want to do can
> be accomplished with the config objects already, I'm not sure how much
> need there is for an extra component.
>
> --
> Matthew Weier O'Phinney
> Project Lead            | [email protected]
> Zend Framework          | http://framework.zend.com/
>



-- 
Vincent Gabriel.
Lead Developer, Senior Support.
Zend Certified Engineer.
Zend Framework Certified Engineer.
-- http://www.vadimg.co.il/

Reply via email to