[Help, urgent] Move node!

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • \(¯`·.¸FlacK¸.·´¯\)

    [Help, urgent] Move node!

    Hi!
    I want to move a node from file "film1" to "film2" that has tag
    "FilmatoPartita ".
    I have write the codo below, but it don't do anything...I don't see the
    error...
    I have forgotten something? Maybe samething to write in the file "film2"?
    Help...it's urgent..thanks! !!



    import java.io.File;
    import javax.xml.parse rs.*;
    import org.w3c.dom.Doc ument;
    import org.w3c.dom.Ele ment;
    import org.w3c.dom.Nod e; // serve per spostare il nodo !
    import org.w3c.dom.Nod eList;


    public class MoveNode {

    public static void main(String[] args) {
    try {

    DocumentBuilder Factory factory = DocumentBuilder Factory.newInst ance();

    DocumentBuilder builder = factory.newDocu mentBuilder();


    Document doc1 = builder.parse( new File("film1.xml ") );

    Document doc2 = builder.parse( new File("film2.xml ") );

    System.out.prin tln("prova");



    Element firstRoot = doc1.getDocumen tElement();

    Element secondRoot = doc2.getDocumen tElement();

    NodeList nodi_figli =
    firstRoot.getEl ementsByTagName ("FilmatoPartit a");
    Element nodo_da_spostar e = (Element)nodi_f igli.item(0);

    Node nuovo_nodo = doc2.importNode (nodo_da_sposta re, true);
    secondRoot.appe ndChild(nuovo_n odo);




    } catch (Exception e) {
    e.printStackTra ce();
    }
    }



  • Martin Honnen

    #2
    Re: [Help, urgent] Move node!



    (¯`·.¸FlacK¸.·´ ¯) wrote:

    [color=blue]
    > I want to move a node from file "film1" to "film2" that has tag
    > "FilmatoPartita ".
    > I have write the codo below, but it don't do anything...I don't see the
    > error...[/color]
    [color=blue]
    > Node nuovo_nodo = doc2.importNode (nodo_da_sposta re, true);
    > secondRoot.appe ndChild(nuovo_n odo);[/color]

    You need to save the DOM tree that currently is in memory, how you do
    that depends on the DOM implementation.

    --

    Martin Honnen

    Comment

    • \(¯`·.¸FlacK¸.·´¯\)

      #3
      Re: [Help, urgent] Move node!

      I use xerces...do you know?

      "Martin Honnen" <mahotrash@yaho o.de> ha scritto nel messaggio
      news:4174f5d0$0 $22613$9b4e6d93 @newsread4.arco r-online.net...[color=blue]
      >
      >
      > (¯`·.¸FlacK¸.·´ ¯) wrote:
      >
      >[color=green]
      > > I want to move a node from file "film1" to "film2" that has tag
      > > "FilmatoPartita ".
      > > I have write the codo below, but it don't do anything...I don't see the
      > > error...[/color]
      >[color=green]
      > > Node nuovo_nodo = doc2.importNode (nodo_da_sposta re, true);
      > > secondRoot.appe ndChild(nuovo_n odo);[/color]
      >
      > You need to save the DOM tree that currently is in memory, how you do
      > that depends on the DOM implementation.
      >
      > --
      >
      > Martin Honnen
      > http://JavaScript.FAQTs.com/[/color]


      Comment

      • Martin Honnen

        #4
        Re: [Help, urgent] Move node!



        (¯`·.¸FlacK¸.·´ ¯) wrote:[color=blue]
        > I use xerces...do you know?[/color]

        There is a serializer in Xerces:



        --

        Martin Honnen

        Comment

        Working...