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

Why Won't This Cast Return the Correct Methods? (Ephesoft)

Okay, so I have been looking at the sample code below from the Ephesoft Developer's Guide... //import java.io.File; // //import javax.xml.transform.Result; //import javax.xml.transform.Source; //import javax.xml.transform.Transformer; //import…
This 0ne Pr0grammer
  • 2,632
  • 14
  • 57
  • 81
0
votes
1 answer

Append data to existing file using JDOM

I'm using the code below. However I want to append new XML to same TXT file one below the other when ever I run the code. is that possible using the JDOM. Pls help me.. xmlOutput.output(doc, new FileWriter("c:\updated.txt")); is the one that needs…
user1669488
  • 227
  • 1
  • 2
  • 10
0
votes
2 answers

Weblogic jdom NoClassDefFoundException

I'm deploying my web application to Weblogic 10.3.6 on localhost and everything works as it should. But when i deploy it to the same version of weblogic which is runnig on a remote server, it throws this: JDOMException:…
0
votes
2 answers

Escaping an xml string in java

I read elements with CDATA sections from a rss-feed which I need to convert to valid xml. The content in the CDATA section is mostly valid xhtml, but some times characters like ampersand appear in attributes (url's). I can use .replaceAll("&",…
Karine
  • 183
  • 4
  • 14
0
votes
1 answer

edit content xml file use JDOM2

I want to ask your advice in next situation. I have xml file with goods. Goods can be not in stock ( in this case I use empty-tag) or in stock (in this case I use tag value_price and dont use tag ). I…
Ray
  • 1,788
  • 7
  • 55
  • 92
0
votes
1 answer

Jdoms annoying textnodes and addContent(index, Element) - schema solutions?

i have some already generated xmls and the application causing problems now needs to add elements to it which need to be at a specific position to be valid with to the applied schemata... now there are two problems the first one is that i have to…
Dennis Ich
  • 3,585
  • 6
  • 27
  • 44
0
votes
2 answers

Comparing efficiency: XSLT Vs XML-Parsing to transform from XML to XML

I've read in a technical paper that using XSLT for making amendments in an XML file is a more efficient and preferable way than using the XML Parser like DOM, JDOM, SAX, JSoup etc. So I wanted to know on which parameters XSLT is more efficient and…
RahulD
  • 709
  • 2
  • 16
  • 39
0
votes
1 answer

SAXBuilder jdom Gives Exception

Here is the code: Representation representation = representItem(exp.getItem(),MediaType.TEXT_XML); Document doc = new SAXBuilder().build(representation.getStream()); XPath xpath =…
rpfujiw
  • 57
  • 1
  • 10
0
votes
1 answer

create more than one element with the same name in JDOM

I am trying to create multiple element with the same name using JDOM, the XML file should be output as following:
0
votes
1 answer

equivalent of normalize function of DOM in JDOM

Can some tell me the function similar to normalize() of DOM in JDOM? I actually want to normalize the XML content and serialise it through XMLSerializer. Thank You Sam
0
votes
1 answer

How can I remove an element from JTree without having it selected using .getSelectionPath()?

I'm trying to remove an Element for my undo function but I want to just remove the last thing added to the JTree. For removal, I'm just modifying my method for Cut: private void performUndoAction() { if (tree != null) { …
Chea Indian
  • 677
  • 3
  • 9
  • 16
0
votes
1 answer

java.io.IOException: Server returned HTTP response code: 500 for URL

I have following code to call URL : http://10.105.0.120/24online/servlet/ClientRegistrationResponse?action=response&phone=919638983856&actioncode=0000 Code : StringBuffer request=new StringBuffer(); request.append(xml); URL…
chetan
  • 3,175
  • 20
  • 72
  • 113
0
votes
1 answer

text parsing to XML using JDOM

I an newbee need you your help. I am converting a text in to XML (with some extra attributes) my text is SPLINE(N, -1.151,1.002, -0.161,0.997, 0.840,-0.004, OUTLINED) i need to have in XML using JDOM like following
Ganderous
  • 11
  • 4
0
votes
1 answer

Make all attribute names lowercase using JDOM

I would like to parse an XML document and change the attribute names to lowercase using JDOM. For example, I would like the following: To become:
Dominic Bou-Samra
  • 14,799
  • 26
  • 100
  • 156
0
votes
2 answers

Can't get Jdom to work with android 1.6 or 2.1 using Eclipse

I'm trying to install jdom onto Eclipse so that I can use it in my Android project. I'd like it to be Android 1.6 but that hasn't worked, I've also been trying to get it to work on android 2.1 and that still hasn't worked. I've downloaded jdom 2.0.2…