Browse by Domains

XML Interview Questions in 2022

Table of contents

Here are the top XML Interview questions that will help you ace those nerve-wracking and perplexing interviews like a pro.

1.What is XML?

XML stands for – eXtensible Markup Language .

XML lays down the framework for defining markup languages. XML is neither programming nor a presentation language. XML is generally used to store text data only. Text data is easy to arrange in XML, which can later be sent as a response from Webserver to the requesting webpage or app as per the codes written.

XML was released in the late ’90s.

2. How to open an XML file?

To open an XML file for editing and re-formatting, you can use any text editor or notepad++, highlighting the syntax, which could be useful in differentiating syntax and other background work.

Opening the XML file in windows:

  • Right click the .XML file 
  • Choose ‘open with.
  • Select your desired editor

Opening the XML file in mac os: 

  • A single click on the .XML file in Finder
  • Press spacebar

3. What is XML used for?

Extensible Markup Language (XML) is used to describe data.

4. How to convert XML to excel?

Step 1: Open Microsoft Excel

Step 2: Click on ‘file’ on the top left corner of MS Excel. If you are using MS Excel version 2007, click on the MS Office logo.

Step 3: You will land on the ‘open’ tab; if not, select the ‘open’ tab. Click ‘browse’ for the MS Excel version of 2010 and above.

Step 4: Double click on the XML file you want to export into MS Excel.

Step 5: Select ‘Open the file without applying a style sheet’ to select the standard format, or ‘Open the file with the stylesheet applied’ to format the data in accordance with the style sheet.

Step 6: Click on ‘save as’ and select ‘Excel Workbook’ from the drop-down menu.

Step 7: Save the file!

5. How to comment in XML?

<!– Write your comment here –>

The above syntax is used as a comment in XML, and these comments don’t show up on the screen.

6. How to display XML data in an HTML page using javascript?

This concept of displaying XML data on an HTML page comes under ‘XML Applications’. Here, we shall use demo.XML as an example.

Example:

This concept of displaying XML data on an HTML page comes under ‘XML Applications’. Here, we shall use demo.XML as an example.

Example:

<!DOCTYPE html>

<html lang="en">

<head>

<meta charset="UTF-8">

<meta name="viewport" content="width=device-width, initial-scale=1.0">

<meta http-equiv="X-UA-Compatible" content="ie=edge">

<title>Demo by Great Learning</title>

</head>

<body>

<div id='content'>

<table id='books' cellpadding='10px' style="text-align:left;">

<thead>

<tr>
 <th>Author</th>
 <th>Title</th>
 <th>Price</th>
 <th>Description</th>
  </tr>                
           
 </thead>
            
<tbody>

            
</tbody>
        
</table>
    
</div>

    
<script>
        
let XMLContent = '';
        
let tableBooks = document.getElementById('books');
 
       fetch('books.XML').then((response)=> {
            response.text().then((XML)=>{
                XMLContent = XML;


                let parser = new DOMParser();
 
               let XMLDOM = parser.parseFromString(XMLContent, 'application/XML');

                let books = XMLDOM.querySelectorAll('book');


                books.forEach(bookXMLNode => {

                    let row = document.createElement('tr');


                    //author
                    let td = document.createElement('td');

                    td.innerText = bookXMLNode.children[0].innerHTML;

                    row.appendChild(td);

                    //  title
  
                  td = document.createElement('td');

                    td.innerText = bookXMLNode.children[1].innerHTML;

                    row.appendChild(td);
                    
//price
  
                  td = document.createElement('td');

                    td.innerText = '$ ' + bookXMLNode.children[3].innerHTML;

                    row.appendChild(td);

                    //description
     
               td = document.createElement('td');

                    td.innerText = bookXMLNode.children[5].innerHTML;

                    row.appendChild(td);


                    tableBooks.children[1].appendChild(row);

                    
                });
  
              
            });
    
    });    
   
 </script>
</body>
</html>

books.XML
<?XML version="1.0"?>

<catalog>

   <book id="bk101">
    
  <author>Novoneel Chakaborty</author>

      <title>Marry me, Stanger</title>
 
     <genre>Thriller</genre>

      <price>175</price>

      <publish_date>2014-11-15</publish_date>

      <description>He has no voice, no face, no name, no identity. BUT HE HAS AN INTENTION</description>

   </book>

   <book id="bk102">

      <author>Novoneel Chakaborty</author>

      <title>All Yours, Stranger</title>

      <genre>=Thriller</genre>

      <price>133.33</price>

      <publish_date>2015-07-14</publish_date>

      <description>He has no voice, no face, no name, no identity. BUT HE HAS AN INTENTION</description>

   </book>

   <book id="bk103">
   
   <author>Novoneel Chakaborty</author>
 
     <title>Forget Me Not, Stranger</title>

      <genre>Thriller</genre>

      <price>133.33</price>
  
    <publish_date>2016-04-13</publish_date>

      <description>He has no voice, no face, no name, no identity. BUT HE HAS AN INTENTION</description>

   </book>

   <book id="bk104">

      <author>Corets, Eva</author>
   
   <title>Oberon's Legacy</title>
    
  <genre>Fantasy</genre>
   
   <price>5.95</price>
      
<publish_date>2001-03-10</publish_date>
 
     <description>In post-apocalypse England, the mysterious 
      agent known only as Oberon helps to create a new life 
      for the inhabitants of London. Sequel to Maeve 
      Ascendant.</description>

   </book>

   <book id="bk105">

      <author>Corets, Eva</author>

      <title>The Sundered Grail</title>
   
   <genre>Fantasy</genre>

      <price>5.95</price>

      <publish_date>2001-09-10</publish_date>
  
    <description>The two daughters of Maeve, half-sisters, 
      battle one another for control of England. Sequel to 
      Oberon's Legacy.</description>
   </book>
   <book id="bk106">
      <author>Randall, Cynthia</author>
      <title>Lover Birds</title>
      <genre>Romance</genre>
      <price>4.95</price>
      <publish_date>2000-09-02</publish_date>
      <description>When Carla meets Paul at an ornithology 
      conference, tempers fly as feathers get ruffled.</description>
   </book>
   <book id="bk107">
      <author>Thurman, Paula</author>
      <title>Splish Splash</title>
      <genre>Romance</genre>
      <price>4.95</price>
      <publish_date>2000-11-02</publish_date>
      <description>A deep sea diver finds true love twenty 
      thousand leagues beneath the sea.</description>

   </book>
   
<book id="bk108">
 
     <author>Knorr, Stefan</author>
 
     <title>Creepy Crawlies</title>
  
    <genre>Horror</genre>
   
   <price>4.95</price>
  
    <publish_date>2000-12-06</publish_date>
   
   <description>An anthology of horror stories about roaches,
      centipedes, scorpions  and other insects.</description>
   </book>
   <book id="bk109">
      <author>Kress, Peter</author>
      <title>Paradox Lost</title>
      <genre>Science Fiction</genre>
      <price>6.95</price>
      <publish_date>2000-11-02</publish_date>
      <description>After an inadvertant trip through a Heisenberg
      Uncertainty Device, James Salway discovers the problems 
      of being quantum.</description>
   </book>
   <book id="bk110">
      <author>O'Brien, Tim</author>
      <title>Microsoft .NET: The Programming Bible</title>
      <genre>Computer</genre>
      <price>36.95</price>
      <publish_date>2000-12-09</publish_date>
      <description>Microsoft's .NET initiative is explored in 
      detail in this deep programmer's reference.</description>
   
</book>

   <book id="bk111">
  
    <author>O'Brien, Tim</author>
   
   <title>MSXML3: A Comprehensive Guide</title>
 
     <genre>Computer</genre>
   
   <price>36.95</price>
   
   <publish_date>2000-12-01</publish_date>

      <description>The Microsoft MSXML3 parser is covered in 
      detail, with attention to XML DOM interfaces, XSLT processing, 
      SAX and more.</description>
   </book>

   <book id="bk112">
      <author>Galos, Mike</author>
      <title>Visual Studio 7: A Comprehensive Guide</title>
      <genre>Computer</genre>
      <price>49.95</price>
      <publish_date>2001-04-16</publish_date>
      <description>Microsoft Visual Studio 7 is explored in depth,
      looking at how Visual Basic, Visual C++, C#, and ASP+ are 
      integrated into a comprehensive development 
      environment.</description>
 
  </book>

</catalog>

7. How to import an XML file in tally?

To import XML file data in tally, follow the below steps.

Step 1: Once you open Tally, you will be welcomed with the StartUp page.

Step 2: Now, press ‘L’ to login as ‘Remote Tally User’ to import your data.

Step 3: You will be prompted with Login Screen, log in with user ID and password.

Step 4: On logging in, you will see ‘Gateway of Tally’ to your screen’s right.

Step 5: Under ‘Masters’ select, ‘Account Info.

Step 6: Under ‘Company Info’, ‘Select Company’, you want to import the XML file.

Step 7: Under ‘Company’, select the company to which you want to import your data; let’s call the ‘Company’ as ‘xyz’.

Step 8: Now, login to ‘xyz.’

Step 9: Under Gateway of Tally, Select ‘Accounts Info’ under ‘Masters

Step 10: Now select ‘trial balance’ as we wanted to update it.

Step 11: Select ‘Outstandings

Step 12: Now, under Types of Vouchers, select ‘Stock Journal’ as we would like to import the XML file of Stock Journal data.

Step 13: Stock Journal by default will be zero, and now select ‘Import Data’ under ‘Utilities’.

Step 14: Select ‘Vouchers’ under ‘Import Data

Step 15: Now, a pop-up screen will appear, now enter the file location of XML as in your pc. Example: C://Downloads\Tally.XML

Step 16: Done!

8.What is DTD in XML?

DTD stands for Document Type Definition. DTD defines the structure, elements and attributes of an XML document. Document Type Definition forms like the structure of the tree and describes something about its data. Document Type Definition (DTD) consists of SGML family structure, like GML, SGML, HTML, XML. In this case, it’s XML.

DTD can be declared inside an XML document or externally.

9.How do you apply a DTD to an XML document?

XML document:

<?XML version=”1.0″ encoding=”standalone=”yes”?>

<!DOCTYPE Catalog SYSTEM “buyerslist.dtd”>

<List>

</List>

The DOCTYPE declaration above contains a reference to a DTD file.

buyerslist.dtd:

<?XML version=”1.0” standalone=”yers”?>

<!DOCTYPE List

[

<!ENTITY loc “Usha’s Bookstore”>

<!ELEMENT List (Book+)>

<!ELEMENT Book (Title,Author*,Publisher*,Pub_Date*)>

<!ELEMENT Title (#PCDATA)*>

<!ATTLIST Title ISBN CDATA #REQUIRED>

<!ELEMENT Author (#PCDATA)*>

<!ATTLIST Author Status CDATA #IMPLIED>

<!ELEMENT Publisher (#PCDATA)*>

<!Element Pub_Date (#PCDATA)*>

]>

<!– Beginning of the Body — >

<List>

</List>

Here, the DTD Code comes after the declaration and the root element.

<!DOCTYPE Catalog [ DTD Code ]> 

That is the entire set of elements beginning from <!ENTITY lic “Usha’s Bookstore”> upto <!ELEMENT Pub_Date (PCDATA)*>, this whole set of coded elements is called DTD Code and is also known as an internal subset if you include DTD in your XML Document.

10.Which is a valid string name in XML?

Element names must start with a letter or underscore. Element names cannot begin with the letters XML (or XML, or XML, etc.) Element names can contain letters, digits, hyphens, underscores, and periods. Element names cannot contain spaces.

11.What is the name of the python 2.x library to parse XML data?

XML.etree.ElementTree

12.How to get attribute value in XML using php?

<?php

$XML=simpleXML_Load_file(“saleslist.XML”) or die(“Error: cannot create object”);

for ($x=0; $x<6; $x++)

echo $XML — > book[$x] — > title[‘bookname’] . “<br>”;

?>

saleslist.XML – is the name of the file we are calling using PHP.

bookname – is the item we are calling for output. 

Here, x is the attribute.

13.What is the difference between XML and HTML?

HTML

  • HTML was designed to display data.
  • HTML tags are predefined.
  • HTML tags are case sensitive.
  • It is not mandatory to close the tag.
  • stylesheets for HTML are optional.
  • HTML is static in nature.

XML

  • It is used to describe data & focus on what data is.
  • XML tags are not predefined.
  • XML tags are not case sensitive.
  • It is mandatory to close the tag.
  • Stylesheets for XML called XSL are compulsory for the formatting of data.
  • XML is dynamic in nature.

14.List some benefits of XML.

Structured Data: Applications can extract the information they need.

Data exchange: This allows you to exchange database contents or other structured information via the internet.

Self-describing: XML is readable and understandable

Search engines: Increases in search relevancy because of contextual information found in XML documents.

15.What do you mean by SAX in XML?

Simple API for XML – SAX is an event-driven algorithm to parse XML documents with API.

16.Are there any rules to be followed when you write an XML document? What are they?

  • All XML must have a root element.
  • All tags have distinct start and end components.
  • All attribute values are quoted.
  • Empty elements are formatted correctly.

17.What do you mean by XSL?

Extensible Stylesheet Language – XSL is one of the stylesheets for XML apart from Cascading Style Sheets (CSS).

18.List the differences between XML DTD and XML schema or XSD.

DTDXSD
Stands for Document Type Definition.Stands for XML Schema.
Derived from SGML syntax.Written in XML.
Doesn’t support datatypes.Supports data types for elements and attributes.
Doesn’t support namespace.Supports namespace.

19.What is element and attribute in an XML document? Define with example.

Element in XML:

Element in XML has starting and ending tags, which also holds text, pictures and attributes.

Example:

<name>The Great Learning</name>

Attribute in XML :

Attributes in XML must be quoted, such as text strings and URLs. Other values such as images, heights and font size give the desired results regardless of the quotation.

Example :

<person gender=”female”> or <person gender=’male’>

Attribute in XML can use both single and double quotes in a specific element in any combination.

Example :

<flower name=”lotus” ‘rose’ ‘lily’>

20.What do you mean by XML data binding? Why is it used?

XML data binding refers to the reading and writing of XML data using a programming language. XML data binding usually occurs using a class library (like C++, Java ), specifically for the given XML data format.

With XML data binding, applications can directly access the required data with the XML file’s created APIs instead of relying on the Document Object Model (DOM) to retrieve the data from the XML file.

21.Explain XMLReader class.

XMLReader is read-only access to a set of XML data in an XML file or document; this process is less memory-consuming. It lets you run through the XML content one element at a time while allowing you to look at the value and then moves on to the next element. 

22.What do you understand by XML encoding error?

XML Encoding error is given out as an ‘error output’ when the validator finds something wrong with the file’s encoding. 

There are two types of XML encoding error :

                                                                     Invalid character found in text.

                                                                     Switching between two different encodings.

Invalid Character found in text

                                                  You will find this type of encoding error if XML contains non-ASCII characters, and the file was saved as a single byte ANSI with no encoding specified.

Switching between two different encodings :

                                                                         You will find this type of encoding error if the double-byte encoding XML file is without encoding or if the same double-byte encoding XML file consists of single-byte encoding.

23.Is XML case sensitive?

Yes, XML is both case-sensitive and case-insensitive. XML tags, Attribute names, Attribute values are case sensitive.

But certain enumerations are case insensitive in XML, such as the use of XSLT.

24.What do you mean by XML Namespace?

XML Namespace is used to provide unique named elements and attributes in an XML document. When you create a Namespace for the first time, it should be in URI format.

25.What is SGML?

SGML stands for Standard Generalized Markup Language, which is a standard for defining markup languages for documents. SGML has the advantage of not being dependent on any specific application. SGML comes from GML, which stands for Generalized Markup Language, allowing users to work on standardised formatting styles.

Standard generalised markup language has two features:

Descriptive Markup

Document Types

26.What is the structure of XML?

XML documents have a hierarchical tree structure, called an XML tree. XML documents must contain a root element (one that is the parent of all other elements). All elements in an XML document can have sub-elements, text and attributes.

27.How to create an XML sitemap?

Step 1: Review the structure of your pages.

The first thing you need to do is look at your website’s existing content and see how everything is structured.

Step 2: Code your URLs

Format each URL with XML tags for each page, which you wish the search engine to crawl for search results.

Step 3: Validate the code.

Validate code with tools like XML SiteMap Validator

Step 4: Add your sitemap to the root and robots.txt

Locate the root folder of your website and add the sitemap file to this folder and also to robots.txt

Step 5: Submit your sitemap.

Submit your website to Google Search Console.

28.What is an XML parser?

An XML parser is a software library that provides an interface for client applications to work with XML documents.

Working of XML Parser: XML Document which undergoes XML parser (usually the API part), and then this API is used in Client Applications.

There are two types of XML parser :

1.DOM 

2.SAX

29.What is the ITR XML file?

ITR stands for Income Tax Return, ITR XML file stands for an XML file that stores income tax information.

This brings us to the end of the XML Interview questions. You are now better equipped to face an XML Interview boldly.
To learn more about XML in detail, check out this XML Tutorial to sharpen your XML skills.

Wondering where to learn the highly coveted in-demand skills for free? Check out the courses on Great Learning Academy.

Avatar photo
Great Learning Team
Great Learning's Blog covers the latest developments and innovations in technology that can be leveraged to build rewarding careers. You'll find career guides, tech tutorials and industry news to keep yourself updated with the fast-changing world of tech and business.

Leave a Comment

Your email address will not be published. Required fields are marked *

Great Learning Free Online Courses
Scroll to Top