Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Inserting Nodes Between Nodes

Status
Not open for further replies.

empiresolutions

Programmer
Jan 20, 2008
4
US
Hi,

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

Code:
    <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:
    <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.
 
woops sorry, my 2nd XML is wrong. here is the correct.

Code:
<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>
 
one other thing... i want to do this in PHP if possible, but other languages are ok.
 
Any language that has an XMLDOM implementation will have an insertBefore method, and they'll all do exactly the same thing.

This is the first result I get when googling for PHP XML insertBefore
replete with sample code and all.

Never be afraid to share your dreams with the world.
There's nothing the world loves more than the taste of really sweet dreams.

Webflo
 
>...into this node between the ending </child01> and beginning <child01>...
What is the amplitude of "between"? If you have a sequence of child01, between which two is the between? or between every two of them? If latter, same content? (I would give you the benefit of the doubt of your best effort. Asking questions is free. Abusing this freedom can backfire.)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top