TestingDocs.com
Software Testing website
  • Automation
    • Selenium
    • JBehave Framework
  • Tutorials
    • MySQL Tutorials
    • Testlink
    • Maven
    • Git
  • IDEs
    • IntelliJ IDEA
    • Eclipse
  • Flowcharts
    • Flowgorithm
    • Raptor
  • About

Automation

XML Parsing with JDOM

Overview

JDOM is an open-source library for Java XML parsing and data manipulations. JDOM was created to be Java-specific and thereby take advantage of Java’s features, like method overloading, collections, reflection etc.

It is available in 2 branches JDOM 2.x and JDOM 1.x . You can find the downloads, source and documentation here: http://www.jdom.org/downloads/

You can find more information about JDOM on the official website: http://www.jdom.org

JDOM versions

JDOM library

The JDOM library contains a lot of packages.

Firstly, the org.jdom2 package holds the classes representing an XML document and its components: Attribute, Document, Element etc

org.jdom2.input package holds classes that build XML documents. The most important class is SAXBuilder. SAXBuilder builds a document by listening to incoming SAX events and building a document. It uses a SAX parser to read the stream and then builds the document according to the SAX parser callbacks.

 

JDOM Packages

 

Thirdly, org.jdom2.output package holds the classes that output XML documents. The most important class is XMLOutputter. It converts documents to a stream of bytes for output to files, streams.

The org.jdom2.transform and org.jdom2.xpath packages have classes that support built-in XSLT transformations and XPath lookup.

XML Parsing

Documents are represented by the org.jdom2.Document class. You can build a document from a file, stream,URL etc. Document class has methods that allow access to the root element as well as the other document-level information.

Document doc = new Document(new Element(“root”));

or build the document with SAX parser, using filename , url etc:

SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(url);

or

SAXBuilder builder = new SAXBuilder();
Document doc = builder.build(new File(filename));

 

Related Posts

Emma Tool

Automation /

Code Coverage Tools

Selenium 4 Automation Project

Automation /

Selenium 4 Project Setup on Ubuntu Linux

Testing webpage mobile-friendliness using a tool

Automation /

Testing webpage mobile-friendliness using a tool

Errors Code Testing Development

Automation /

Error Severity Metrics

Automation Environment Setup Verification

Automation /

Automation Environment Setup Verification

‹ What is Proof of Concept ( PoC )› Network Protocol Analyzer WireShark

Recent Posts

  • MS Access Data Types
  • Install RAPTOR Avalonia on CentOS
  • Download RAPTOR Avalonia Edition on Windows
  • npm doctor command
  • Build & Run CLion Project
  • Create New CLion C Project on Windows
  • Configure CLion Toolchains on Windows
  • Launch CLion IDE on Windows
  • Activate CLion IDE
  • CLion IDE for C/C++ Development

Back to Top

Links

  • Contact
  • Privacy Policy
  • Cookie Policy

www.TestingDocs.com

Go to mobile version