Reply
Inserting Nodes between Nodes
Old 01-21-2008, 03:35 AM Inserting Nodes between Nodes
Extreme Talker

Posts: 153
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. one other thing... i want to do this in PHP if possible, but other languages are ok.

Last edited by empiresolutions : 01-21-2008 at 04:55 AM.
empiresolutions is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 01-21-2008, 03:56 AM Re: Inserting Nodes between Nodes
chrishirst's Avatar
Super Moderator

Posts: 13,626
Location: Blackpool. UK
Your tags would be incorrectly nested in your example
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>
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-21-2008, 04:01 AM Re: Inserting Nodes between Nodes
Extreme Talker

Posts: 153
woops..

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>
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 01-21-2008, 05:30 AM Re: Inserting Nodes between Nodes
chrishirst's Avatar
Super Moderator

Posts: 13,626
Location: Blackpool. UK
So you are looking for code to read the node structure and insert another <child02> element.
Not how to structure the nodes.

so a PHP question really
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-21-2008, 12:47 PM Re: Inserting Nodes between Nodes
Extreme Talker

Posts: 153
Quote:
Originally Posted by chrishirst View Post
So you are looking for code to read the node structure and insert another <child02> element.
Not how to structure the nodes.

so a PHP question really
Yes, yes and yes
empiresolutions is offline
Reply With Quote
View Public Profile
 
Old 01-21-2008, 03:21 PM Re: Inserting Nodes between Nodes
chrishirst's Avatar
Super Moderator

Posts: 13,626
Location: Blackpool. UK
as in the other thread

take a look at Thierry's code class in

http://www.webmaster-talk.com/php-fo...unce-make.html
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 01-21-2008, 04:42 PM Re: Inserting Nodes between Nodes
tripy's Avatar
Fetchez la vache!

Posts: 2,055
Name: Thierry
Location: In the void
Ok...
Here, if you want a copy of the node, then cloneNode() [ http://www.php.net/manual/en/functio...-clonenode.php ] is the solution.

But first, tell me if it's really a copy of the node that you need, or just another node that may be similar or not to the previous.
Because I really don't see the logic here....
__________________
Listen to the ducky: "This is awesome!!!"

tripy is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Inserting Nodes between Nodes
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.14730 seconds with 12 queries