473,387 Members | 1,757 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,387 software developers and data experts.

Merge 2 xml file using jdom

Hello everyone, i'd like to know how can I merge 2 xml files into one using jdom.
The 2 xml files have the same structure.
file1.xml:
<results>
<book>
<title> hello1</title>
<author< celia1</author>
</book>
</results>

file2.xml
<results>
<book>
<title> hello2</title>
<author< celia2</author>
</book>
</results>

I would like to obtain one file containing:

<results>
<book>
<title> hello1</title>
<author< celia1</author>
</book>

<book>
<title> hello2</title>
<author< celia2</author>
</book>

</results>

Thank you for your help!!
Jul 31 '07 #1
7 2580
r035198x
13,262 8TB
Hello everyone, i'd like to know how can I merge 2 xml files into one using jdom.
The 2 xml files have the same structure.
file1.xml:
<results>
<book>
<title> hello1</title>
<author< celia1</author>
</book>
</results>

file2.xml
<results>
<book>
<title> hello2</title>
<author< celia2</author>
</book>
</results>

I would like to obtain one file containing:

<results>
<book>
<title> hello1</title>
<author< celia1</author>
</book>

<book>
<title> hello2</title>
<author< celia2</author>
</book>

</results>

Thank you for your help!!
What do you have so far?
Do you know anything about JAXP?
Jul 31 '07 #2
What do you have so far?
Do you know anything about JAXP?
No I don't. Do i absolutly need to use JAXP?
Jul 31 '07 #3
JosAH
11,448 Expert 8TB
No I don't. Do i absolutly need to use JAXP?
Don't be afraid of those silly (nested) acronyms. The good ol' SAX parser is even
part of that bloated API. It's just that those W3C loonies want to move those
bloated xml text files all over this valley or tears back and forth over and over again.

kind regards,

Jos
Jul 31 '07 #4
I'm not sure I've understood all you said. anyways do you think it is possible to merge 2 xml files that have the same structure using jdom without using xsl?
Jul 31 '07 #5
r035198x
13,262 8TB
I'm not sure I've understood all you said. anyways do you think it is possible to merge 2 xml files that have the same structure using jdom without using xsl?
JAXP - Java API for XML Processing
Jul 31 '07 #6
JosAH
11,448 Expert 8TB
JAXP - Java API for XML Processing
AIABA = AIABA Is Another Bloody Acronym.

kind regards,

Jos ;-)
Jul 31 '07 #7
r035198x
13,262 8TB
AIABA = AIABA Is Another Bloody Acronym.

kind regards,

Jos ;-)
There you go again
Jul 31 '07 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Praveen Chhangani | last post by:
Folks, I was wondering if it were possible to convert an org.jdom.doc to an org.w3c.doc document. Essentially what I have is an already parsed document using jdom and I would like to use the...
1
by: Lana | last post by:
Hello all! I need to add another element to an XML file along with its content, but encountered a problem. I tried with the code provided, but it happens so that i can't run the program from my...
3
by: Michael | last post by:
hello, I'm a java programmer, and my program will require to parse XML documents and extract data from it, then built a new XML document. Should JDOM or Xerces be the best for me? Please help....
1
by: Bernd Oninger | last post by:
When I compile my java source with jdom b10 the compiler tells me that the instrcution XMLOutputter outputter = new XMLOutputter(" ", true); Outputter.output(doc, new FileWriter("t.xml")); is...
3
by: Bernd Oninger | last post by:
When I run the successfully compiled java source shown at the end I got a runtime error: Exception in thread "main" java.lang.NoClassDefFoundError: org/jdom/Content Where is the missing class ?...
8
by: Squirrel | last post by:
Hi everyone, I've created a mail merge Word doc. (using Office XP) , the data source is an Access query. Functionality I'm attempting to set up is: User sets a boolean field to true for...
2
by: zhengwt | last post by:
I used JDOM.jar to process xml-based document. Recently, I meet such a problem that I can not solve. First, I use the following code generate xml text: Element root = new Element("Root");...
1
by: vj | last post by:
How i can populate all fileds dynamically in jsp page based on contents found in xml file? I have written jsp servlets and java class file. i transferred automatic data from jsp to servlet then to...
2
by: celiaachkar | last post by:
Hello everyone, i'd like to know how can I merge 2 xml files into one using jdom. The 2 xml files have the same structure. file1.xml: <results> <book> <title> hello1</title> <author<...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.