Page 1 of 1

Inserting Nodes between Nodes

Posted: Mon Jan 21, 2008 11:27 am
by cesarcesar
Hi,

XML novice here with another question. I need to add a XML node like,

Code: Select all


    <child01>
<child02>
<text></text>
<image>image 1</image>
<image>image 2</image>
</child02>
</child01>
into this node between the ending </child01> and beginning <child01> of the

Code: Select all


    <child01>
<child02>
<text></text>
<image>image 1</image>
<image>image 2</image>
</child02>
</child01>
<child01>
<child02>
<text></text>
<image>image 1</image>
<image>image 2</image>
</child02>
</child01>
Does this make sense? I guess im looking for a way to say/do... make a new node with the following values and place it between these other two nodes.

I still am learning XML but i think this can be done.

Posted: Mon Jan 21, 2008 11:57 am
by cesarcesar
woops sorry, my 2nd XML is wrong. here is the correct.

Code: Select all


<child01>
<child02>
<text></text>
<image>image 1</image>
<image>image 2</image>
</child02>
<child02>
<text></text>
<image>image 1</image>
<image>image 2</image>
</child02>
</child01>
<child01>
<child02>
<text></text>
<image>image 1</image>
<image>image 2</image>
</child02>
<child02>
<text></text>
<image>image 1</image>
<image>image 2</image>
</child02>
</child01>

Posted: Mon Jan 21, 2008 12:34 pm
by Dan
Hello,

Probably it can be done using XSLT. A good step by step tutorial may be found here:
http://www.zvon.org/xxl/XSLTutorial/Output/index.html

Regards,
Dan

Posted: Mon Jan 21, 2008 12:46 pm
by cesarcesar
thanks for the XSLT info. I have heard of, but not looked into it. im really trying to accomplish this using PHP though. i guesses i could have added that to the post.

i DO plan to read up on XSLT though