[Help, urgent] Move node!

  • Thread starter \(¯`·.¸FlacK¸.·´¯\)
  • Start date
¯

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

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

Martin Honnen

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

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

I use xerces...do you know?

Martin Honnen said:
(¯`·.¸FlacK¸.·´¯) wrote:




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
473,994
Messages
2,570,222
Members
46,809
Latest member
moe77

Latest Threads

Top