473,410 Members | 1,952 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,410 software developers and data experts.

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

Jul 20 '05 #1
3 2084


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

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #2
I use xerces...do you know?

"Martin Honnen" <ma*******@yahoo.de> ha scritto nel messaggio
news:41***********************@newsread4.arcor-online.net...


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

--

Martin Honnen
http://JavaScript.FAQTs.com/

Jul 20 '05 #3


(¯`·.¸FlacK¸.·´¯) wrote:
I use xerces...do you know?


There is a serializer in Xerces:
http://xml.apache.org/xerces2-j/java...erializer.html
http://xml.apache.org/xerces2-j/java...erializer.html

--

Martin Honnen
http://JavaScript.FAQTs.com/
Jul 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: ComputerSmith | last post by:
Hi all. I have programmed VB6 apps before, ones that use dropdown listboxes, text boxes, etc... normal stuff. I was asked by a friend to write a "simple" app that I am unsure how to proceed...
9
by: jab | last post by:
Je veux lier (join) une table qui se trouve dans une database avec une qui se trouve dans une autre database. Les 2 databases sont sur le même serveur en l'occurence DB2/NT 7.2.9. J'ai créé un...
8
by: jason | last post by:
Hello everyone, I am looking for an algorithm that would take an incremental value and map that to a case-inspecific alphanumeric string. However, I don't want the string to simply step through...
1
by: apacheutara | last post by:
hai.. i juz started learning C++ language & started to try creating a program. its a simple contacts list. here's the code: ========================================================= ...
1
by: dasilva109 | last post by:
Hi guys I am new to C++ and need urgent help with this part of my code for a uni coursework I have to submit by Thursday //ClientData.h #ifndef CLIENTDATA_H #define CLIENTDATA_H #include...
6
by: sandy | last post by:
I am creating a class (or so I hope) which is to be a JobCollection, linked list of 'Job'. Job is another class already created. JobCollection is just the linked list manager. I have to have...
5
by: koonda | last post by:
Hi all, I am a student and I have a project due 20th of this month, I mean May 20, 2007 after 8 days. The project is about creating a Connect Four Game. I have found some code examples on the...
4
by: moon24 | last post by:
Hi im working with linked list and i have to implement a function that deletes the duplicates of a number. for example if given 2 7 1 7 12 7 then the result should be 2 7 1 12 here is what I have:...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.