Tuesday, July 28, 2009

How do I add elements to an xml document with the php xml dom?

For example, given the xml file below:





%26lt;?xml version="1.0" encoding="utf-8"?%26gt;


%26lt;root%26gt;


%26lt;child%26gt;abcdefgh%26lt;/child%26gt;


%26lt;secondchild%26gt;ijklm%26lt;/secondchild%26gt;


%26lt;/root%26gt;





How would I add an element %26lt;thirdchild%26gt; after %26lt;secondchild%26gt; with the php xml dom?

How do I add elements to an xml document with the php xml dom?
If you are using php5 you can use the addchild method of the simplexml class.





http://uk2.php.net/manual/en/function.si...





There is example code on that page.

stamen

No comments:

Post a Comment