Reputation: 22565
I am trying to write a XML file with Zend_Config_Writer_Xml. I found out a problem that I can't write multiple items under a root. I would like to do,
<root>
<item name="test"></item>
<item name="test2"></item>
</root>
I can't find a method to do this on zend documentation.
Please advise me.
Upvotes: 1
Views: 753
Reputation: 11042
Standard writer doesn't do exactly that, but it works like this: if you do:
$config = new Zend_Config(array(), true);
$config->root = array("test1" => 1, "test2" => array(1,2));
$writer = new Zend_Config_Writer_Xml();
$writer->write('config.xml', $config);
then what you get is:
<zend-config xmlns:zf="http://framework.zend.com/xml/zend-config-xml/1.0/">
<root>
<test1>1</test1>
<test2>1</test2>
<test2>2</test2>
</root>
</zend-config>
I don't think standard writer does attributes, you'd need to override it for that.
Upvotes: 1