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();
}
}
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();
}
}
Comment