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
1 answer

Want to avoid extra stuff when writing xml to output file

My question is when after modifying my XML file I write it to an output XML file using XMLOutputter of JDOM it writes a lot of extra stuff in the output XML file. I want to avoid that. My original xml snippet is:
SKV
  • 21
  • 2
0
votes
1 answer

dynamically set value to xml using jdom

I have XML that have no fixed format I have following code using org.w3c.dom to dynamically set value to same XML. public String generateXML(String[] tags,String[] tagValues,String xmlfilePath){ String strXML = ""; try{ …
chetan
  • 3,175
  • 20
  • 72
  • 113
0
votes
1 answer

Getting java.lang.VerifyError exception while using JDOM

Please help me to find out the way to get out of this, while using JDOM API, I am using root.addContent(new Element("name").setText("Enlightenment")); method to add the element in XML but during runtime I am getting the following…
GLADIATOR
  • 119
  • 1
  • 12
0
votes
1 answer

Generate Binary Tree form N aire Tree- recursive method doesn't work

Im trying to convert a general tree (tree that have one or more children ) to a binary tree .My general tree is represented by an XML file name "1.xml" that contain : so i can…
Wassim Sboui
  • 1,692
  • 7
  • 30
  • 48
0
votes
1 answer

Reading XML data between tags

I have a XML for which i am writing a servlet to pick up contents from the XML. One such tag is Jonathan Kendrick I need to get author value for this. because of : I tried using namespace and using escape sequence for…
CodeMonkey
  • 2,265
  • 9
  • 48
  • 94
0
votes
1 answer

Edit XML file using JDOM

I want to add xmlns:atom to the root element of an XML file, the file already exists, I just want to modify it by adding the adding xmlns. The rest of the files is to be left unchanged. As an example, I have in file and I want to…
Dipen Jogi
  • 151
  • 1
  • 7
0
votes
2 answers

Leaving duplicate namespace declarations with JDOM

I'm trying to read existing xml file, that has duplicated namespace declarations. It is important to me to leave this declarations for further processing. Earlier I was using XERCES implementation of org.w3c.dom api to read such a documents, and all…
0
votes
2 answers

How to validate an XML document against an XSD schema using JDom

I am working on an application that used JDom for parsing XML documents. Following is the existing code: private Document openDocumentAtPath(File file) { // Create a sax builder for building the JDOM document SAXBuilder builder =…
Ankit
  • 6,772
  • 11
  • 48
  • 84
0
votes
1 answer

why can't I load this URL with JDOM? Browser spoofing?

I'm writing some code to load and parse HTML docs from the web. I'm using JDOM like so: SAXBuilder parser = new SAXBuilder(); Document document = (Document)parser.build("http://www.google.com"); Element rootNode = document.getRootElement(); /* and…
user550738
0
votes
2 answers

Remove XML attribute using JDOM API?

I have a JDOM element like the following Example:XML(JDOM Element)
11111 60821894 938338789
Prabhath kesav
  • 428
  • 3
  • 6
  • 21
0
votes
1 answer

Issues in Parsing XML

I have already existing classes,I want to check whether there is any way to map the following XML into existing class. Existing XML(jdom Element)
11111
Prabhath kesav
  • 428
  • 3
  • 6
  • 21
0
votes
2 answers

XML Parsing using JDOM fails

I am using JDOM parser to parse a XML i created using feedrinse. XML is available at: http://www.feedrinse.com/services/rinse/?rinsedurl=396ac3b0142bb6360003c8dbac4f8d47 My code is to parse every title,link,pubDate element and store them in a new…
CodeMonkey
  • 2,265
  • 9
  • 48
  • 94
0
votes
2 answers

JDOM Throwing Parse Exceptions with bad ascii characters

I'm using JDOM with my Android project, and every time I get a certain set of characters in my server response, I end up with these error messages: 05-04 10:08:46.277: E/PARSE: org.jdom.input.JDOMParseException: Error on line 95 of document UTF-8:…
RyanInBinary
  • 1,533
  • 3
  • 19
  • 47
0
votes
4 answers

Parsing XML File using Jdom and SAX Parser

I have a XML in the format: ... 36.48617 -89.97065 00000001 pages…
0
votes
1 answer

How to avoid jdom sax builder include line separator

I use jdom SAXBuilder to get a XML document. My problem is that in the document returned, every element is preceded by a line separator ('/n'). I looked at jdom docs and seems that this is the normal behavior of the parser. I'd like to avoid it but…
flavio
  • 11
  • 2
  • 5