XML Interview Questions and Answers

What is XML?
XML stands for extensible markup language much like as a HTML. XML was designed to carry data, not to display data. XML loosely couples disparate applications or systems utilizing JMS, Web services etc. XML uses the same building blocks that HTML does: elements attributes and values. XML tags are not predefined. You must define your own tags.
Why is XML important?

Scalable: Since XML is not in a binary format you can create and edit files with anything and it's also easy to debug. XML can be used to efficiently store small amounts of data like configuration files (web.xml, application.xml, strutsconfig. xml etc) to large company wide data with the help of XML stored in the database. 
Fast Access: XML documents benefit from their hierarchical structure. Hierarchical structures are generally faster to access because you can drill down to the section you are interested in. 
Easy to identify and use: XML not only displays the data but also tells you what kind of data you have. The mark up tags identifies and groups the information so that different information can be identified by different application. 
Style ability: XML is style-free and whenever different styles of output are required the same XML can be used with different style-sheets (XSL) to produce output in XHTML, PDF, TEXT, another XML format etc. 
Linkability, in-line usability, universally accepted standard with free/inexpensive tools

Describe the differences between XML and HTML?

designed to transport and store data, with focus on what data is designed to display data, with focus on how data looks
User definable tags Defined set of tags designed for web display
Content driven Format driven
End tags required for well formed documents End tags not required
Quotes required around attributes values Quotes not required
Slash required in empty tags Slash not required


Is XML meant to replace HTML?

No, they both go together one is for describing data while other is for displaying data.

What is CDATA section in XML?

All data is normally parsed in XML but if you want to exclude some elements you will need to put those elements in CDATA.

What is XSL?
XSL (the extensible Style sheet Language) is used to transform XML document to some other document. So its transformation document which can convert XML to some other document. For instance you can apply XSL to XML and convert it to HTML document or probably CSV files.

Is XML case sensitive?
XML tags are case sensitive. The tag is different from the tag .
What is DOM?
A DOM (Document Object Model) defines a standard way for accessing and manipulating documents. The XML DOM defines a standard way for accessing and manipulating XML documents. The XML DOM views an XML document as a tree-structure. All elements can be accessed through the DOM tree. Their content (text and attributes) can be modified or deleted, and new elements can be created. The elements, their text, and their attributes are all known as nodes.
Define DTD (Document Type definition)?
DTD - Document Type Definition defines the legal building blocks of an XML document. It defines the document structure with a list of legal elements and attributes. XML DTD is a rule book that an XML document follows. Once DTD is ready, you can create number of XML documents following the same rules specified in the DTD. DTD can be internal or external DTD. The internal DTD is included in the XML document, while external DTD exists outside the content of the documents.

Explain DTD and schema?

A DTD provides a list of the elements, attributes, comments, notes, and entities contained in an XML or HTML document and indicate their relationship with each other. 

DTD supports two types of data - CDATA and PCDATA.
Schema means the organization and the structure of a database. Schema supports numeric, Boolean and String data types and suitable for applications that developed in a programming language. Schema supports custom data types. Schema supports encapsulation and inheritance concepts. Schema supports for WEB services, XSLT.

E.g.: An XML schema is a description of XML document. It is expressed in terms of constraints on the structure and content of documents.

What are the standard ways of parsing XML document? or What is a XML parser?

XML parser sits in between the XML document and the application who want to use the XML document. Parser exposes set of well defined interfaces which can be used by the application for adding, modifying and deleting the XML document contents. 

There are two standard specifications which are very common and should be followed by a XML parser:- 

DOM: - Document Object Model.
IT is an open standard. The XML file is arranged in a tree fashion. DOM supports random access to the data of XML file. 
DOM is a W3C recommended way for treating XML documents. In DOM we load entire XML document into memory and allows us to manipulate the structure and data of XML document. 

SAX: - Simple API for XML. 
SAX is event driven way for processing XML documents. In DOM we load the whole XML document in to memory and then application manipulates the XML document. But this is not always the best way to process large XML documents which have huge data elements. For instance you only want one element from the whole XML document or you only want to see if the XML is proper which means loading the whole XML in memory will be quiet resource intensive. SAX parsers parse the XML document sequentially and emit events like start and end of the document, elements, text content etc. So applications who are interested in processing these events can register implementations of callback interfaces. 
SAX parser then only sends those event messages which the application has demanded. 

In What scenarios will you use a DOM parser and SAX parser?

If we do not need all the data from the XML file then SAX approach is much preferred than DOM as DOM can quiet memory intensive. In short if you need large portion of the XML document its better to have DOM. 
With SAX parser you have to write more code than DOM. 
If we want to write the XML in to a file DOM is the efficient way to do it. 
Some time you only need to validate the XML structure and do not want to retrieve any Data for those instances SAX is the right approach. 

Define XPATH and what is XSLT?

XPATH is an XML query language to select specific parts of an XML document. Using XPATH we can address or filter elements and text in a XML document. For instance a simple XPATH expression like "book/price" states find "price" node which are children of "Invoice" node. XSLT is a rule based language used to transform XML documents in to other file formats. XSLT are nothing but generic transformation rules which can be applied to transform XML document to HTML, CS, Rich text etc.

What is SOAP and how does it relate to XML?
The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML.

Latest Updates


By what number should we multiply -1/5 so that the product may be 9/25?

Profit and Loss

A person sells an article for Rs 550, gaining 1/10 of its cost price. Its gain percentage is.


If 3x + 2y = 12 and xy = 6, then 9x2 + 4y2 = ______.

Volume and Surface Area

In a temple there are 25 cylindrical pillars. The radius of each pillar is 28cm and height 4m. The total cost of painting the curved surface area of pillars at the rate of Rs. 8 per m2 is:

Problems on Ages

After 12 years, I shall be 3 times as old as I was 4 years ago. My present age is:

Square and Cube Root

The smallest number by which 1100 must be multiplied so that the product becomes a perfect square is____.


What is the probability that a number selected from the numbers 1, 2, 3,…….,25 is a prime number, when each of the given numbers is equally likely to be selected?

Square and Cube Root

What is the smallest number by which 3087 must be divided so that the quotient is a perfect cube?


The most comfortable distance at which one can read with a normal eye is:


Cholera is caused by:

Write the name of reptile with four chambered heart?

Compound Interest

Raj borrowed Rs. 5000 at 10% per annum on simple interest and lent the same amount at 15% per annum on compound interest. At the end of 2 years, he would ?


If the area of a square is 16 cm2, then the area of the square joining the mid-points of the sides is?

General Knowledge of MP

Vidisha is situated on the banks of river?

General Knowledge of World

When is the Human Rights Day celebrated?

Profit and Loss

By selling coconuts at the rate of Rs. 6/- each, a trader gained 20%. Find the cost of 100 coconuts?

General Knowledge of India

How many coastal state are in India?


A person is to count 4500 currency notes. Let an denote the number of notes he counts in the nth minute. If a1 = a2 = .... = a10 = 150 and a10 , a11 ,... are in an AP with common difference – 2, then the time taken by him to count all notes is ?