(¯`·.¸FlacK¸.·´¯ )
Usenet Archive
- Joined
- Oct 19, 2004
- Messages
- 3
- Reaction score
- 0
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.parsers.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node; // serve per spostare il nodo !
import org.w3c.dom.NodeList;
public class MoveNode {
public static void main(String args) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance;
DocumentBuilder builder = factory.newDocumentBuilder;
Document doc1 = builder.parse( new File("film1.xml") );
Document doc2 = builder.parse( new File("film2.xml") );
System.out.println("prova");
Element firstRoot = doc1.getDocumentElement;
Element secondRoot = doc2.getDocumentElement;
NodeList nodi_figli =
firstRoot.getElementsByTagName("FilmatoPartita");
Element nodo_da_spostare = (Element)nodi_figli.item(0);
Node nuovo_nodo = doc2.importNode(nodo_da_spostare, true); secondRoot.appendChild(nuovo_nodo);
} catch (Exception e) {
e.printStackTrace;
}
}
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.parsers.*;
import org.w3c.dom.Document;
import org.w3c.dom.Element;
import org.w3c.dom.Node; // serve per spostare il nodo !
import org.w3c.dom.NodeList;
public class MoveNode {
public static void main(String args) {
try {
DocumentBuilderFactory factory = DocumentBuilderFactory.newInstance;
DocumentBuilder builder = factory.newDocumentBuilder;
Document doc1 = builder.parse( new File("film1.xml") );
Document doc2 = builder.parse( new File("film2.xml") );
System.out.println("prova");
Element firstRoot = doc1.getDocumentElement;
Element secondRoot = doc2.getDocumentElement;
NodeList nodi_figli =
firstRoot.getElementsByTagName("FilmatoPartita");
Element nodo_da_spostare = (Element)nodi_figli.item(0);
Node nuovo_nodo = doc2.importNode(nodo_da_spostare, true); secondRoot.appendChild(nuovo_nodo);
} catch (Exception e) {
e.printStackTrace;
}
}