I see when i started to learn ZF2 that we can use Zend\Config\Writer to write config in XML and put it into a file. I saw the PhP class DomDocument too. And i saw also SimpleXMLDocument.
I have to make a complex and extremely heavy XML with a lot of data from my Database. With DOMDocument, for 30% of the work, my code is already too complicated and not maintainable anymore.
This is a sample of how my XML has to be :
//...a lot more XML before
<Lines>
<line lineNum="Num">
</line>
<line lineNum="Num2">
</line>
</Lines>
//A lot more XML after
Those line can be created by a foreach loop. Zend\Config\Writer can't do that (especially for attribute parts) does it ?
My question is : Is exist a better way that i don't know yet for generate an XML with Zend Framework 2 ?
P.S :I'm looking for Object oriented programming solution.
Thanks for help.
I'm looking for an ZF2 internal solution too, @Hooli. Hoping to get some answers on Twitter too: What is the best way to generate / write #XML in #ZF2? Make use of \Zend\Feed\Writer or an external class like #SimpleXML? Any known module?
Maybe one can use the Zend\Feed\Writer for these cases as a workaround but I would prefer a ZF2 module or similar.
Otherwise @Tim is right, SimpleXML is a good solution. For bigger files XMLWriter is recommended.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments