In this article, you will see list of XML interview questions with answers, which can help you learn more about XML before proceeding for any technical interview.

xml-interview-questions-min.png

1. What is XML?

XML stands for Extensible Markup Language, it can be used to transfer data between services like Web API and Front-end of any website.

XML is a simple and flexible markup language in text format.

XML is basically used to decribe data and it also support user defined tags.

Example of XML

<?xml version="1.0" encoding="UTF-8"?>
<book>
 <name>A Song of Ice and Fire</name>
 <author>George R. R. Martin</author>
 <language>English</language>
 <genre>Epic fantasy</genre>
</book>

2. What can be alternative of XML?

JSON can be used as an alternative of XML, although now a days JSON is preferred but XML is still widely used in data-processing between the internet.

3. What is difference between XML and HTML?

Here are the difference between XML and HTML

  • XML is used to describe the data and transfer data, while HTML is mark-up language used to show data.
  • XML is case-senstive while HTML is not.
  • XML supports user-defined tags while HTML has pre-defined tags.
  • XML is content driven???????????????? whereas HTML is format driven????????.
  • XML provides namespaces support while HTML doesn't provide namespaces support.
  • In XML we need to close tags, while HTML it is not true for all tags.

4. What is XML schema (XSD)?

XML Schema Definition (XSD) language is the current standard schema language for all XML documents and data.

The XML Schema definition language (XSD) enables you to define the structure and data types for XML documents.

An XML Schema defines the elements, attributes, and data types that conform to the World Wide Web Consortium (W3C) XML Schema.

An XML Schema is composed of the top-level schema element.The schema element contains type definitions (simpleType and complexType elements) and attribute and element declarations.

Source

5. What are the disadvantages of using XML?

  • XML requires a processing application
  • Cannot create custom tags.
  • Requires more data processing power and traffic for small amount of useful data, like below example, where information is just 1 byte 
    <CustomerOrderMessage>
    <OrderNumber>1</OrderNumber>
    </CustomerOrderMessage>?
  • Too many tags for a single document structure could interfere with XML's ability to process the information.
  • No intrinsic data type support

6. What is DTD?

DTD stands for Description of Type of Document and it is used to define building blocks of XML.

DTD defines rules for a specific type of document as below:

  • Names of elements
  • Order of elements
  • Proper nesting and containment of elements
  • Element attributes

7. How do you execute an XML file?

This is trick question, an XML file can not be executed or run. You can open it or View it but you cannot execute it. You can open and view file using any XML editor or even using Notepad.

8. What is element, attribute and namespace in XML?

Element: XML Elements are represented by tags and it explains about the data, like <language>English</language>, Where language is element

Attribute: It specifies more details of any XML element, for example, in below XML "id" is an attribute of element "order"

 <Order id="1">
     <Price> 2300</Price>
  <Order>

Namespace: XML namespace are basically used to avoid clash between two similar XML's, it's just like we provide namespace to any class in C# or provide package in Java.

You may also like to read:

ASP.NET MVC Interview Questions and Answers

OOPS interview questions in C# (With Answers)