PHP XML - Inserting a XML node at a specific location

Posted by Blueboye on Stack Overflow See other posts from Stack Overflow or by Blueboye
Published on 2010-06-16T15:19:26Z Indexed on 2010/06/16 15:22 UTC
Read the original article Hit count: 333

Filed under:
|

Hi Guys,

I want to insert a node with children at a specific location in the XML file. How do I do it?

For eg. If I have an XML like:

<myvalues>
 <image name="img01">
    <src>test</src>
 </image>

 <image name="img02">
    <src>test</src>
 </image>

 <image name="img03">
    <src>test</src>
 </image>
</myvalues>

I want to insert:

<image name="img11">
  <src>test2</src>
</image>

between <image name="img01"> & <image name="img02">. How do I do this? I am using SimpleXML right now to read the XML.

Thanks.

© Stack Overflow or respective owner

Related posts about php

Related posts about Xml