[Help, urgent] Move node!

(¯`·.¸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;
}
}
 

Martin Honnen

Usenet Archive
Joined
Apr 8, 2000
Messages
6,174
Reaction score
0
(¯`·.¸FlacK¸.·´¯) wrote:

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...
Node nuovo_nodo = doc2.importNode(nodo_da_spostare, true); secondRoot.appendChild(nuovo_nodo);

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

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
548,208
Messages
3,104,802
Members
249,594
Latest member
henrywalsh

Latest Threads

Top