XML (Extensible Markup Language) acts as a mode of communication between different applications to transport and store data. Java contains various libraries that are used to parse, modify, or inquire about the XML documents.
XML Documents consist of elements similar to HTML, and each element has a starting tag, content, and ending tag. XML consists of one root element which encloses all the other elements inside it. XML is a case sensitive language, and XML files are hierarchical.
Basic Example:
<?xml version="1.0"?> <!-- This is a comment --> <address> <name>ABC</name> <street> GT </street> <telephone number= "0123"/> </address>
Features of XML:
- XML is a markup language.
- XML is also a tag-based language similar to HTML, but the tags are not predefined in XML.
- You can define your tags in XML. Hence it is also said to be an extensible language.
- W3C recommends XML.
- XML is a platform-independent language.
- No programming is required to modify the data, and thus look and feel of the documents can be easily changed.
- XML is a future-oriented language.
Uses of XML:
- Web Publishing: With the help of XML, you can create interactive web pages and creating e-commerce applications. In XML, you need to store data only once, and then this content can be used for different viewers or devices.
- Web Searching and automating Web Tasks: XML makes it easy to return useful information while searching the web. Web Agents and Robots (programs that are used to automate Web Searches.)
- General Applications: XML makes it easy for general applications to use, store, transmit, and display data.
- E-business Applications: XML helps in more accessibility of EDI (electronic data interchange) that is used for information interchange, business-to-business transactions, and business-to-consumer transactions.
- Metadata Applications: With the help of XML, it becomes easy to express metadata in a reusable and portable format.
- Pervasive Computing: It provides structured and portable information to display on wireless devices like PDAs (Personal Digital Assistants), cellular phones, and others.
Advantages of XML:
- XML is technology independent. Any technology can use XML for storing and parsing the data.
- XML is readable and easy to understand.
- Custom tags are very easy to create and use in XML.
- XML can be easily validated using XSD and DTD.
Disadvantages of XML:
- XML contains lots of redundant data.
- XML is a verbose language, so its file size increases the transmission and storage costs.
Technologies Related to XML:
Technology | Meaning | Description |
XHTML | Extensible HTML | This is developed to make HTML more extensible and inter-operability with other data. |
XML DOM | XML Document Object Model | This is used to access and manipulate XML. |
XSL | Extensible Style Sheet Language | This is used to transform XML into other formats, formatting XML to screen, paper, etc. |
XQuery | XML Query Language | This is used to query XML based data. |
DTD | Document Type Definition | This is used to define legal elements in an XML document. |
XSD | XML Schema Definition | It is an alternative to DTD. |
XLink | XML linking language | This is used to create Hyperlinks. |
XPointer | XML pointer language | This is used to address components of XML data. |
SOAP | Simple object access protocol | This helps to exchange information over HTTP. |
WSDL | web services description languages | It is used to describe the functionality offered by web services. |
RDF | web services description languages | This is used to describe web resources. |
SVG | Scalable vector graphics | This is used to support graphics and animation. |
RSS | Really simple syndication | This is used to handle web content syndication. |
Example:
<?xml version="1.0" encoding="UTF-8"?> <bookstore> <book category="cooking"> <title lang="en">Everyday Italian</title> <author>Giada De Laurentiis</author> <year>2005</year> <price>30.00</price> </book> <book category="children"> <title lang="en">Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="web"> <title lang="en">XQuery Kick Start</title> <author>James McGovern</author> <author>Per Bothner</author> <author>Kurt Cagle</author> <author>James Linn</author> <author>Vaidyanathan Nagarajan</author> <year>2003</year> <price>49.99</price> </book> <book category="web" cover="paperback"> <title lang="en">Learning XML</title> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore>
8 Responses