Jump to content

Inserting Nodes between Nodes


cesarcesar

Recommended Posts

Hi,

 

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

 

    <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

 

 

    <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.

Link to comment
Share on other sites

Hi,

 

Referring you code .

 

what is the need of <child02> how it differe if the <text><image> falls in <child01> ????

this won't be considered as proper XML.what you can do is

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

This make some sense i suppose.As i am not aware what you are trying to do this may not be the best XML format but this will be lighter and faster to parse compare to the previous.

 

Regards

Link to comment
Share on other sites

woops sorry, my 2nd XML is wrong. here is the correct.

 

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

Link to comment
Share on other sites

one other thing... i want to do this in PHP if possible, but other languages are ok.

 

Dear, you can to XML creation and parsing of it in PHP.This language has potential to do it faster and better.But again i would like to check your second XML

if <child01> is not similar with second occurance of <child01> then its okie but if it is similart then create only one xml <tag> for it take example

 

hild01>

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

<child02> it sud not be child01

              <child022>

<text></text>

<image>image 1</image>

<image>image 2</image>

</child022>

<child022>

<text></text>

<image>image 1</image>

<image>image 2</image>

</child022>

</child02>

 

Regards

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.