[xml] adding new nodes at a specific place



Hello,

just another question, which I could not resolve. I parse a file and 
want to add a new node at a specific place. The file looks like this:

<rootnode>
  <johndoe attr="1">
    <foobar with_attr="first">...</foobar>
    <foobar with_attr="second">...</foobar>
    ...
  </johndoe>
  <johndoe attr="2">
    <foobar with_attr="first">...</foobar>
    <foobat with_attr="second">...</foobar>
     ...
  </johndoe>
  <johndoe attr="3">
    ....
  </johndoe>

  <tingletangle attr="anotherattr">
   <anoth_node tofu="moretofu">...</anoth_node>
    ...
  </tingletangle>
   ...
</rootnode>

Now I want to add a new <johndoe> - node between 
the last <johndoe> (here with the id 3) and <tingletangle>.

I could not get a possible solution for this. The only one which I got,
was to get the last <johndoe>, and add a new one in it, at the end of the 
last <johndoe>. But it has to be necessary, that the new <johndoe> - node
is between those both, because another parsing automatically will get the
sum of all childnodes of the rootnode, which are called <johndoe>. If the added
<johndoe> - node is added in another one, the parsing routine will not get the correct
sum. Is there any possibility to realize this? 

Thanks
Marcus

Attachment: pgp0pSqfpxSiE.pgp
Description: PGP signature



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]