Inserting Nodes between Nodes

Questions about XML that are not covered by the other forums should go here.
cesarcesar
Posts: 5
Joined: Mon Jan 21, 2008 10:59 am

Inserting Nodes between Nodes

Post 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.
cesarcesar
Posts: 5
Joined: Mon Jan 21, 2008 10:59 am

Post 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>
Dan
Posts: 501
Joined: Mon Feb 03, 2003 10:56 am

Post 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
cesarcesar
Posts: 5
Joined: Mon Jan 21, 2008 10:59 am

Post 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
Post Reply