Java XML – Overview

XML (Extensible Markup Language) is a very popular simple text-based language that can be used as a mode of communication between different applications. It is considered as a standard means to transport and store data. JAVA provides excellent support and a rich set of libraries to parse, modify or inquire XML documents. This tutorial will teach you basic XML concepts and the usage of various types of Java based XML parsers in a simple and intuitive way.

Audience

This tutorial has been prepared for beginners to help them understand the basic-to-advanced concepts related to XML parsing using Java Programming language.

After completing this tutorial, you will find yourself at a moderate level of expertise in XML parsing using Java from where you can take yourself to higher levels of expertise.

Java XML – Overview

What is XML?

XML is a simple text-based language which was designed to store and transport data in plain text format. It stands for Extensible Markup Language. Following are some of the salient features of XML.

  • XML is a markup language.
  • XML is a tag based language like HTML.
  • XML tags are not predefined like HTML.
  • You can define your own tags which is why it is called extensible language.
  • XML tags are designed to be self-descriptive.
  • XML is W3C Recommendation for data storage and data transfer.

Example

<?xml version = "1.0"?>
<Class>
   <Name>First</Name>
   <Sections>
      <Section>
         <Name>A</Name>
         <Students>
            <Student>Rohan</Student>
            <Student>Mohan</Student>
            <Student>Sohan</Student>
            <Student>Lalit</Student>
            <Student>Vinay</Student>
         </Students>
      </Section>
      
      <Section>
         <Name>B</Name>
         <Students>
            <Student>Robert</Student>
            <Student>Julie</Student>
            <Student>Kalie</Student>
            <Student>Michael</Student>
         </Students>
      </Section>
   </Sections>
</Class>

Advantages

Following are the advantages that XML provides โˆ’

  • Technology agnostic โˆ’ Being plain text, XML is technology independent. It can be used by any technology for data storage and data transfer purpose.
  • Human readable โˆ’ XML uses simple text format. It is human readable and understandable.
  • Extensible โˆ’ In XML, custom tags can be created and used very easily.
  • Allow Validation โˆ’ Using XSD, DTD and XML structures can be validated easily.

Disadvantages

Following are the disadvantages of using XML โˆ’

  • Redundant Syntax โˆ’ Normally XML files contain a lot of repetitive terms.
  • Verbose โˆ’ Being a verbose language, XML file size increases the transmission and storage costs.

Leave a Reply