magento -- 用Magento的方式读写XML
I will be using Varien_Simplexml_Element class to read write xml nodes. The path to this class file is lib/Varien/Simplexml/Element.php
Here is a sample XML file which I am going to read through Magento code. I will also be adding an XML node to the following XML data.
Here is the Magento/PHP code to read the XML data. I have kept the XML file in the root directory of Magento installation. The XML file is named test.xml. At first, the XML file is loaded and then it’s node are read with getNode function. Then, I have printed the result.
You can add node with the setNode function. Here, I have set a node inside the node ‘modules’. The name of my new node is ‘mukesh’ and it’s value is ‘chapagain’.
Hope this helps. Thanks for reading.
From Mukesh Chapagain's Blog, post Magento: Read Write XML