Here we have mentioned most frequently asked XML Interview Questions and Answers specially for freshers and experienced.


 

1. What is a markup language?

Ans:

Markup languages are designed for presentation of text in different formats, and it can also be used for transporting and storing data. This markup language specifies the code for formatting, layout and style of data .This markup code is called Tag.
HTML and XML are examples of Markup Language.

2. What is XML?

Ans:

XML is called Extensible Markup Language which is designed to carry or transport and store data. XML tags are not as predefined as HTML, but we can define our own user tags for simplicity. It mainly concentrates on storing of data, not on displaying of data.

3. What are the features of XML?

Ans:

Main features of XML are:
• Very easy to learn and implement
• XML files are text files, and no editor is required
• Minimal and a limited number of syntax rules in XML
• It is extensible, and it specifies that structural rules of tags

4. What are the differences between HTML and XML?

Ans:

Following are the differences between HTML and XML:

HTML

XML

Markup language used to display data

Markup language used to store data

Case Insensitive

Case sensitive

Designing web pages

Used to transport and store data

Predefined Tags

Custom Tags

Does not Preserve white spaces

Preserve white spaces

Static

Dynamic

5. Which tag is used to find the version of XML and the syntax?

Ans:

Declaring the XML version is very important for each XML document and platform needs to be specified in which it is running.

6. What is XML DOM Document?

Ans:

XML Document object represents the whole XML document, and it is the root of a document tree. It gives access to entire XML document – Nodes and Elements, and it has its own properties.

7. What is XPath?

Ans:

XPath is used to find information in an XML document and contains standard functions. XPath is the major element in XSLT, and it is w3c recommendation.

8. What is an attribute?

Ans:

An attribute provides more or additional information about an element than otherwise. Attribute name can be given to an element person.

9. Can we have empty XML tags?

Ans:

Yes, we can have empty tags in XML. Empty tags are used to indicate elements that have no textual content.

10. What are the advantages of XML DOM Document?

Ans:

Advantages of XML DOM:
• XML structure is traversable, and it can be randomly accessed by traversing the tree.
• XML structure is modifiable, and values can be added, changed and removed



 

11. What are the basic rules while writing XML?

Ans:

These are the basic rules while writing XML:
• All XML should have a root element
• All tags should be closed
• XML tags are case sensitive
• All tags should be nested properly
• Tag names cannot contain spaces
• Attribute value should appear within quotes
• White space is preserved

12. What is XML Element?

Ans:

An XML document contains XML Elements, and it starts from an element’s start tag to end tag. It can contain:
• Other elements within main element
• An Attribute
• text

13. What is CDATA?

Ans:

CDATA is unparsed character data that cannot be parsed by the XML parser. Character < and > are illegal in XML elements.

14. How comment can be represented in XML?

Ans:

Comment can be represented as <!- – comments – -> as like HTML. This comment symbol is applicable for single or multiple lines.

15. What are XML Namespaces?

Ans:

XML namespaces are used to avoid element name conflicts, and it can be avoided by using prefix before the name.

16. What is XML Parser?

Ans:

XML Parser is used to convert from XML document into an XML DOM object which can be written in Javascript.

17. What is XSL?

Ans:

XSL is a language used with XML for expressing style sheets as like CSS. It describes how to display an XML document for a given type.

18. Who is responsible for XML?

Ans:

XML is a recommendation of the W3C – World Wide Web Consortium and the development are supervised by XML working group.

19. What is an XML Schema?

Ans:

An XML schema gives the definition of an XML document, and it has following:
• Elements and attributes
• Elements that are child elements
• Order of child elements
• Data types of elements and attributes

20. What is well formed XML document?

Ans:

A well-formed XML document must follow the following rules –
• Every start tag should end with an end tag
• XML tags are case sensitive
• Empty tags are necessary to close with a forward slash
• All tags should be properly nested




 

21. Why XML has been used for development?

Ans:

XML is used for development for following reasons:
• Used for Database driven websites
• Used to store data for e-commerce websites
• Used to transport and store data on internet
• XML is used for database and flat files
• Generate dynamic content by applying different style sheets

22. What is SGML?

Ans:

SGML is large and powerful Standard Generalized markup Language which is used to define descriptions of the structure of different types of electronic document.

23.Can I execute a XML?

Ans:

No, we cannot execute XML, and it is not a programming language to execute. It is just a markup language to represent the data.

24. What are the special characters used in XML?

Ans:

<, > and & are the special characters used in XML. Because these characters are used for making tags.

25. What software is available for XML?

Ans:

There are thousands of programs available for XML and updated list will be present in http://xml.coverpages.org.

26. Whether graphics can be used in XML? If so, How?

Ans:

Yes, Graphics can be included in XML by using XLink and XPointer specifications. It supports graphic file formats like GIF, JPG, TIFF, PNG, CGM, EPS and SVG.
XLink:

<description
xlink:type="simple"
xlink:href="http://show.com/Cinema.gif"
xlink:show="new">

XPointer:

<description
xlink:type="simple"
xlink:href="http://show.com/Cinema.gif#Shownumber"
xlink:show="new">

27. Can I replace HTML with XML?

Ans:

No, XML is not a replacement of HTML. XML provides an alternative approach to define own set of markup elements, and it is used for processing and storing data.

28. How can I include conditional statements in XML?

Ans:

We cannot include conditional statement as like programming language.

29. What are the benefits of XML?

Ans:

Benefits of XML are
• Simple to read and understand
• XML can be done with a text editor
• Extensibility – No fixed tags
• Self – descriptive
• Can embed multiple data types

30. What are the disadvantages of XML?

Ans:

Following are the disadvantages of XML:
• XML will be just a text file if elements and attributes are not defined properly.
• Overlapping markup is not permitted


 

31. What is DTD?

Ans:

DTD is abbreviated as Document Type Definition and it is defined to build legal building blocks of an XML document. It defines the XML document structure with elements and attributes.

32. Why XSLT is important for XML?

Ans:

XSLT is abbreviated as eXtensible Sytlesheet Language Transformation which is used to transform an XML document to HTML before it is displayed to the browser.

33. What are nested elements in XML?

Ans:

If one or more elements are nested inside the root element is called nested element. Nesting can be easy to understand and also keeps order in an XML document.

34. What is XQuery?

Ans:

XQuery was designed to query XML data which is nothing but SQL for database tables. XQuery is used to fetch the data from the XML file.

35. What is XLink and XPointer?

Ans:

XLink is the standard way of creating hyperlinks in the XML files. Xpointer which allows those hyperlinks to point to more specific parts of the XML file or document.

36. Why XML editor is needed instead of Notepad?

Ans:

XML editors are required to write error free XML documents, and it is used to validate against DTD or schema. Editors are able to check:
• Open and Close Tags
• XML against DTD
• XML against Schema
• Color code on XML Syntax

37. What is XML Encoding?

Ans:

XML documents may contain Non-ASCII characters like French and Norwegian characters. XML Encoding is used to avoid errors and XML files have to be saved as Unicode.

38. Which XML is set to be valid XML?

Ans:

When the XML file is validated against the Document Type Definition(DTD), then it is called valid XML. DTD is nothing but it defines the structure of an XML file.

39. What is Simple Element?

Ans:

A simple element contain only text and following are the kinds of Simple Element:
No attributes
Doesn’t contain other elements
It cannot be empty

40. What is Complex Element?

Ans:

A complex element contain other elements or attributes and following are kinds of Complex Elements:
It has empty elements
It contain other elements
It contain only text
It contain both other elements and text



 

41. Is there a way to describe XML data?

Ans:

Yes, XML uses Document Type Definition (DTD) to describe the data.

42. What are the three parts of XSL?

Ans:

XSL consists of three parts:
XSLT – Used to transform XML documents
XPath – Used for navigating in XML documents
XSL-FO – Used for formatting XML documents

43. What is the correct syntax when we define XML version?

Ans:

The correct declarative syntax used to define XML version.

44. If XML attribute name itself has double quotes, then how it can be represented?

Ans:

Attribute name can be represented within single quotes if double quotes are present in the attribute name.

45. What are the types of XML Parsers?

Ans:

There are two types of parsers – Non-Validating and Validating Parsers. Name itself implies Non-Validating will not validate the XML and Validating parser will validate the XML with DTD.

46. Whether root element is required for XML? If so, how many root elements are required?

Ans:

Yes, root element is required, and it can have only one root element in each XML.

47. What is XML Signature?

Ans:

XML Signature is recommended by W3C, and it acts as a digital signature for XML documents. If the signature is contained outside the document, it is called detached signature. If it contains inside the XML document, then it is called Enveloping signature.

48. What is Data Island?

Ans:

An XML Data island is XML data embedded into a HTML page. This works only with the Internet.

49. What is DiffGram in XML?

Ans:

A DiffGram is an XML format which is used to find current and original versions of XML document.

50. What is SAX?

Ans:

SAX is an interface processing XML documents using events.




 

51. What is XML?

Ans:

XML stands for eXtensible Markup Language. It is a simple and flexible markup language. It is known as universal language for data on the web because XML documents can be created and used in any language. It is universal standard for information interchange.
XML technology facilitates you to create your own markup language.

52. How XML is different from HTML?

Ans:

HTML stands for Hyper Text Markup Language while XML stands for eXtensible Markup Language. The key differences between HTML and XML are given below:

No.

HTML

XML

1)

HTML is used to display data and focuses on how data looks.

XML is a software and hardware independent tool used to transport and store data. It focuses on what data is.

2)

HTML is a markup language itself.

XML provides a framework to define markup languages.

3)

HTML is not case sensitive.

XML is case sensitive.

4)

HTML is a presentation language.

XML is neither a presentation language nor a programming language.

53. What is the meaning of version in XML?

Ans:

Version is a tag used to show which version of XML is used.

54. What are the benefits of XML?

Ans:

These are the main benefits of using XML.
Simplicity: Very easy to read and understand the information coded in XML.
Openness: It is a W3C standard, endorsed by software industry market leaders.
Extensibility: It is extensible because it has no fixed set of tags. You can define them as you need.
Self-descriptive: XML documents do not need special schema set-up like traditional databases to store data. XML documents can be stored without such definitions, because they contain metadata in the form of tags and attributes.
Scalable: XML is not in binary format so you can create and edit files with anything and it is also easy to debug.
Fast access: XML documents are arranged in hierarchical form so it is comparatively faster.

55. What is XML DOM?

Ans:

DOM stands for Document Object Model which is used to describe the logical structure of XML document. It is a hierarchical model that provides a way to access and manipulate an XML document.
DOM methods and objects can be used with any languages like C#, VB, JavaScript and VB Script.

56. What is SAX in XML?

Ans:

SAX stands for Simple API for XML. It is a sequential access parser. It is a simple API for XML which provides a mechanism for reading data from an XML document. It is an alternative of DOM. DOM operates on the documents as whole, SAX parsers operate on each piece of the XML document sequentially.
SAX has no formal specification like DOM and consumes less memory. But it can be used to read the XML document only not write.

57. What is XSNL?

Ans:

XSNL is an XML search neutral language. This language acts between the meta search interface and targeted system.

58. What is a well formed XML document?

Ans:

A syntactically correct document is called well formed XML document. A well formed XML document must follow the XML?s basic rules of syntax:
It must have a closing tag.
The closing tag must exactly match the open tag: XML is case sensitive.
All elements should be included within a single root tag.
Child elements must be closed within parent tag.

59. What is a valid XML document?

Ans:

A structurally correct element is called a valid XML document. It should follow some predefined rules of a specific type of document. These rules determine the type of data that each part of the document can contain. These rules can be written by the author of an XML document or someone other.

60. What is DTD?

Ans:

DTD stands for Document Type Definition. It defines a leading building block of an XML document. It defines:
Names of elements
How and where they can be used
Element attributes
Proper nesting


 

61. How can you apply a DTD to an XML document?

Ans:

To apply a DTD to an XML document, you can:
Use the DTD element definition within the XML document itself.
Provide a DTD as a separate file and reference its name in XML document.

62. What are the basic rules to write XML document?

Ans:

You should consider the following rules to write an XML document.
It should have a root element.
All tags must be closed.
Spaces are not allowed in tag names.
All tags must be nested properly.
XML tags are case sensitive.
Use the attribute values within quotes.
Whitespace is preserved in XML.

63. What is XSL?

Ans:

XSL stands for Extensible Stylesheet Language. It is a language for expressing stylesheets. These stylesheets are like CSS which describes how to display an XML document of a given type.

64. What is XPath in XML?

Ans:

XPath is a technology used in XML. It is used to retrieve elements from XML documents. XPath expressions can be used to locate and retrieve elements, attributes and values from XML files because XML documents are structured. It is similar to SQL.
As SQL is used to retrieve data from database, XPath is used to retrieve data from XML.

65. What is XSLT?

Ans:

XSLT is a popular XML technology which is used to transform one XML file to other format like HTML etc. XSLT is like a language which has its own syntax, functions and operator to transform XML documents. XSLT is also used to display data present in XML files as HTML pages.

66. What is the difference between XML DTD and XML schema or XSD?

Ans:

XSL stands for Extensible Stylesheet Language. It is a language for expressing stylesheets. These stylesheets are like CSS which describes how to display an XML document of a given type.
DTD stands for Document Type Definition whereas XSD stands for XML Schema Definition.
DTD does not support namespaces. It has its own set of keywords to define a schema whereas XSD uses its own set of namespaces and elements to define the schema.
DTD is the predecessor of XML schema whereas XML schema is a new technology, some XML parser do not support it yet.

67. Is XML meant to be a replacement of HTML?

Ans:

No, both languages have their own specification and used for different purposes. XML is used to describes data while HTML focus on how to display data.

68. Define element and attribute in an XML document.

Ans:

From a start tag to end tag everything you see in a XML document, is XML element. It can contain other elements, attributes and texts.
An Attribute is a value that is used to define additional information about the element.

69. What is the difference between simple element and complex element?

Ans:

In XML, simple elements are text-based elements. It contains less attributes, child elements, and cannot be left empty.
But, complex elements can hold multiple attributes and elements. It can contain additional sub elements and empty element also.

70. Define the concept of XPOINTER.

Ans:

XPOINTER is used to point data within XML document. It is used to locate the particular part of the XML document. It is a W3C recommendation.
See this example:
address.xml#pointer(/ descendant ::streetnumber[@id =9])
In this example, XPOINTER points “streetnumber = 9” in “address.xml”.



 

71. What is XML data binding? Why is it used?

Ans:

XML data binding is the process of representing the information in an XML document as an object in computer memory.
XML data binding is used to short your development effort, simplify maintenance, increase reliability. It saves your development time and money. It makes working with XML data very intuitive.

72. What is XML encoding error?

Ans:

There are two types of XML encoding errors:
An invalid character was found in text content.
Switching from current encoding to specified encoding not supported.
These errors occur because XML document can contain non ASCII characters like Norwegian and French. These errors can be avoided by specifying the XML encoding Unicode.

73. What are the different XML API’s?

Ans:

Tree-based API: It compiles an XML document in a tree like structure and loads it into the memory. You can traverse and change the tree structure. Tree based API’s are useful for a wide range of applications. Example of tree-based API is DOM parser.
Event-based API: An event based API provides the reports to an application about the parsing event. It uses a set of built-in call back functions. Example of event-based API is SAX parser.

74. What is XmlReader class? Explain.

Ans:

The XmlrReader class represents a reader that provides fast, noncached, forward-only access to XML data. You need to import the following namespaces to work with XmlReader class in .NET.
In VB:
Imports System.Xml
In C#:
using System.Xml;

75. What is the difference between CDATA and PCDATA?

Ans:

CDATA means unparsed character data whereas PCDATA means parsed character data.

76. What is XQuery?

Ans:

XQuery is a query language that is used to retrieve data from XML document.

77. What is XML Namespace?

Ans:

A namespace is a qualified name that is associated with the DTD/Schema location .
A document may have duplicate elements and attributes. So, the namespace defines a way to compare duplicate elements and attribute names.

78. What is SGML?

Ans:

SGML is a vast and powerful generalized markup language that is used to define descriptions for the structure of several electronic documents.

79. Can we use graphics in XML?

Ans:

Yes, graphics can be stored in XML file by using XLink and XPointer. It supports graphics like GIF, JPG, TIFF, PNG, CGM, EPS, SVG.

80. Is XML case sensitive?

Ans:

Yes, XML is a case sensitive language.