Questions tagged [jdom]

JDOM is an open source library for working with a Java representation of an XML document. JDOM provides a way to represent that document for easy and efficient reading, manipulation, and writing. It has a straightforward API, is a lightweight and fast, and is optimized for the Java programmer.

JDOM is an open source library (hosted on gitub) for working with a Java representation of an XML document. JDOM provides a way to represent that document for easy and efficient reading, manipulation, and writing.

The major features of JDOM that make it easier to use are:

  • it has a straightforward API
  • it is lightweight and fast (relative to other in-memory models)
  • the in-memory model of the document is always well-formed.
  • it is optimized for the Java programmer.
    • It uses standard Java collection structures instead of some other form of containers
    • All Collections are correctly typed using Java Generics
    • It provides simple and high-performance access to XML Parsers and 'outputters'
    • it integrates well with data that is read from, or written to SAX, DOM, and StAX API's

While SAX (and sometimes DOM and StAX) can be used to build JDOM documents, the JDOM API is not like those. Still, JDOM is able to interface well with programs that expect SAX, StAX, or DOM input, or expect JDOM to provide such output.

JDOM is not a wrapper for the W3C's DOM, or another version of DOM. JDOM is a Java-based "document object model" for XML files. JDOM serves the same purpose as DOM, but is easier to use.

JDOM is not an XML parser (like Xerces). It is a document object model that uses XML parsers to build documents. JDOM's SAXBuilder class for example uses the SAX events generated by an XML parser to build a JDOM tree. The default XML parser used by JDOM is the JAXP-selected parser, but JDOM can use nearly any parser.

JDOM 2.0.0 was released in 2012 and introduced full support for Java Generics and an improved XPath interface as well as many other features.

JDOM 1.1.3 is still supported and even runs on Java 1.1.2

485 questions
0
votes
2 answers

Use JDOM to query an XML file? Like SQL but with XML?

I'm making a 2D game with LWJGL at the moment. I'm using JDOM as a base for storing information in XML files. My items.xml file is structured as follows: 1 Item This is an…
Darren
  • 1,774
  • 4
  • 21
  • 32
0
votes
1 answer

Generic XML utility -- in java jdom

Please suggest me how to do the following utility in java, Want to create the generic java class to generate the XML with JDOM. Class is capable enough to generate the any xml structure in runtime depends on parameter pass -- How? For example, In…
GLADIATOR
  • 119
  • 1
  • 12
0
votes
3 answers

Size of jdom document vs single variables

I planning on reading profile data from a xml file in JSP. Now i can either read it and store the important information in single session variables or just put the whole section from the xml file in a jdom document and put that into a single session…
John Frost
  • 673
  • 1
  • 10
  • 24
-1
votes
1 answer

Parsing XML with JDOM

I want to use JDOM, so I want to Know the equivalent to this code written by DOM: DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); URL Url = new URL(url); Document doc = builder.parse(Url.openStream()); I use…
Marie
  • 137
  • 1
  • 3
  • 19
-1
votes
1 answer

Difference between setattribute and addContent in jdom? I dont understand what is the difference

Could someone explain what is the difference between setattribute and addContent in Jdom, when I use this for an element, could someone explain the difference? I have read the API but I was unable to understand that
mikroi
  • 3
  • 1
-1
votes
1 answer

How to get specified attributes from for loop?

I try to get "Value" String which have the largest value of NumVotes. After that I would like do to simple asserion (I know how to do it), but I have problems how to get this "Value". I don't have idea and knowledge about it. public class…
-1
votes
1 answer

how can i import packages in visual studio code?

I use actually visual studio Code ( for Java ) and I need to use Jdom. For that, I need to import a package/library. I know how I can do this import on eclipse, but how can I do that with visual studio code?
Orion
  • 158
  • 1
  • 7
-1
votes
3 answers

Stream to String in Jdom

How to preserve white space in jdom? i get the below error: org.jdom.JDOMException: Error on line 1: Content is not allowed in prolog This is my code, kindly tell the solution for this code... import org.jdom.*; import org.jdom.input.*; import…
saran
  • 1,273
  • 4
  • 19
  • 34
-1
votes
2 answers

Java xml error encoding utf-8

Well When I write it shows strange characters, I have been reading and I have to use FileOutputStream to solve the problem, but I am very new and I do not know how to do it. My code is wrong, there is an error doing, build (xml) and I do not know if…
Raúl Puro
  • 35
  • 1
  • 2
  • 7
-1
votes
2 answers

What is the best approach to create multiple xml elements with same name with Java?

Let's say I want to create this xml: text 1 text 2 text 3 . . . n elements With a java loop, I…
Lauro182
  • 1,597
  • 3
  • 15
  • 41
-1
votes
1 answer

Get certain childrens with JDOM

I currently have this line of code : org.jdom2.Element typeContent = root.getChildren().get(objTypeIndex); This was working fine until you added children with other names. Then it started to bug and change the data in the wrong child. If I got…
Sembrano
  • 1,127
  • 4
  • 18
  • 28
-1
votes
4 answers

updating xml node with JDOM

I have problem with updating data in my xml file. My xml file looks like this : ..... x2000 fast train NULL 0
Sembrano
  • 1,127
  • 4
  • 18
  • 28
-1
votes
1 answer

how to save/write special character in XML?

I want to save/write the xml that time I cant save/write the special character in XML file using JDOM. When I am trying to save this type of character it give me ?? masrks instead of character. I am search on this problem but I cant get the proper…
vijayk
  • 2,633
  • 14
  • 38
  • 59
-1
votes
1 answer

Filling template xml in memory using Java and JDOM?

I want to create a XML from a template during runtime in Java using JDOM. Below is a sample template .. I want to load this template file…
KK99
  • 1,971
  • 7
  • 31
  • 64
-1
votes
2 answers

JDOM duplicate elements

I have XML: COMPUTER68 INSTALLED I would like to have duplicate content of MXAUTHCISet. Result would…
ja jaaaa
  • 115
  • 4
  • 15
1 2 3
32
33