Top 30 XML Interview Questions
The blog provides the commonly asked XML Interview Questions, XML interview questions on XML benefits, XML interview questions on SAX Parser, XML interview questions on DOM Parser, XML interview questions on Valid XML Document, XML interview questions on XML HttpRequest, XML interview questions on namespace, XML interview questions on XML vs HTML , XML interview questions on XLink , Xpointer and many more
XML Interview Questions are useful for the preparation of competitive exams or IT professionals job openings.
XML Interview Questions & Answers
1) What is XML?
XML stands for Extensible Markup language. XML is a markup language which is defined as a common standard to store and transport data.
XML specific data attributes can be sent from any programming language and can be read through any programming language as each programming language uses the same XML standard.
XML allows to create user-defined tags for storing and displaying the data which are both human and machine readable
For instance, a sample XML structure for User Info
<?xml version="1.0" encoding="UTF-8"?> <userInfo> <firstName>Mohit</firstName> <lastName>Sharma</lastName> <City>Chandigarh</City> </userInfo>
2) Describe the benefits of XML ?
The below given are the XML benefits
- XML is W3C Standard endorsed by software industry market leaders
- XML provides tags which easy to understand and learn
- XML supports tags and that makes it Extensible language
- XML is scalable as it is written using tags that contains text
- XML documents are faster to access and read
- XML provides flexibility as tags can be added and edited easily
3) Describe well-formed XML document?
The well formed XML documents should have features
- XML document must have the root element
- XML document should have the Version specified
- XML elements should be properly nested
- XML tags should be closed properly
- XML values should be defined within double-quotes ( ” ” )
4) What is an XMl Element ?
An XML document contains XML elements to form a complete XML data request. An XML tag defined with the start and end tag including the value is termed as an XML element. An XML element can contain text, attributes, other XML elements.
An XML example displaying the XML Elements
<onlinestore>
<clothes category="women">
<type>Jeans</type>
<brand>Levis</brand>
<year>2021</year>
<price>79.99</price>
</clothes>
<clothes category="men">
<type>Jeans</type>
<brand>Diesel</brand>
<year>2021</year>
<price>99.99</price>
</clothes>
</onlinestore>5) What is an XML Attribute?
XML elements can have attributes which allows to contain data related to specific XML element in the XML document
In the above example , element clothes ahs the attribute category defined
<!-- exmaple for XML attribute --> <clothes category="women"> or <user name="Mohit Sharma">
6) What is Uniform Resource Identifier (URI) ?
A Uniform Resource Identifier (URI) is a string of characters which helps in identifying an Internet Resource
Types of Uniform Resource Identifier (URI):
- Uniform Resource Locator (URL): helps in identifying an Internet Domain Address
- Uniform Resource Name (URN) : helps in identifying an Internet Resource Name
7) What is XML Namespace ?
XML namespace allows XML element to avoid naming conflict. There could be possibility of having same element name when referenced in the XML document.
- The XML namespace should be defined with prefix namespace
- The XML namespace should be defined in the xmlns attribute .
- The xmlns attribute should be in the start tag of the XML element
- The XML namespace syntax is: xmlns:prefix=”URI”
8) Explain XML HttpRequest ?
The XML HttRequest is :
- The XML HttpRequest is an object supported by all browsers to request data from server
- The XML HttpRequest allows to update the web page without reloading the page
- The XML HttpRequest send data request to web server at the time of page load
- The XML HttpRequest receives requested data from web server when the page is loaded
- The XML HttpRequest sends updated data to web server
- The XML HttpRequest receives and sends the data using AJAX
- The responseText property in the XML HttpRequest returns response as a string
- The responseXML property in the XML HttpRequest returns response as XML DOM Object
9) Explain XML Parser ?
The XML Parser is :
- XML Parser is used to access and make changes in the XML
- All browsers supports built-in XML Parser
- The XML Parser converts the received text into XML DOM Object
- XML DOM (Document Object Model) defines the methods and properties for updating XML data
- The XML DOM Parser is created using syntax parser = new DOMParser();
- The XML parser creates a new XML DOM object using the text string
xmlDoc = parser.parseFromString(text,”text/xml”);
<!DOCTYPE html>
<html>
<body>
<p id="store"></p>
<script>
var parser, xmlDoc;
var text = "<onlinestore> <clothes>" +
"<type>Jeans</type> " +
" <brand>Levis</brand> " +
" <year>2021</year> " +
" <price>79.99</price> " +
" </clothes> </onlinestore> " ;
parser = new DOMParser();
xmlDoc = parser.parseFromString(text,"text/xml");
document.getElementById("store").innerHTML =
xmlDoc.getElementsByTagName("type")[0].childNodes[0].nodeValue;
</script>
</body>
</html>
Output:
Jeans10) How a version is shown in XML ?
XML provides version tag to show the XML version
<?xml version="1.0" encoding="UTF-8"?>
11) Difference between XML and HTML ?
| XML | HTML |
|---|---|
| An XML is a Tool based on W3C Standard to store and transport data | HTML is a language that interprets the received data |
| XML ensures what data is being sent | HTML ensure how data is displayed |
| XML is case sensitive | HTML is not case sensitive |
| XML allows to create user-defined tags | HTML provides built-in tags |
| A well formed XML should have the closing tag | Closing tags are not mandatory in HTML |
| XML is dynamic | HTML is static |
| XML preserves whitespaces | HTML does not preserve whitespaces |
12) What is XML DOM ?
XML DOM stands for Document Object Model which represents the XML Document Structure. XML DOM allows to access and manipulate XML data
13) Explain SAX in XML ?
- SAX stands for Simple API for XML
- SAX is used as an alternative approach for DOM Parser
- SAX allows to read data from the XML Document but does not allows XML update
- SAX is a sequential XML Parser as it reads the XML document sequentially
- SAX consumes less memory as it does not maintain any specifications like DOM
14) What is DTD in XML ?
DTD stands for Document Type Definition and is used to provide the XML Document Structure using XML elements and attributes. A XML document is considered a “well-formed” document if it is validated against DTD
Example for Well formed XML with DTD
<!DOCTYPE – indicates the root element for DT
<!ELEMENT – indicates the XML element of #PCDATA type
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE UserInfo "user.dtd"> <userInfo> <firstName>Mohit</firstName> <lastName>Sharma</lastName> <city>Chandigarh</city> </userInfo> <!-- user.dtd--> <!ELEMENT employee (firstName,lastName,city)> <!ELEMENT firstName (#PCDATA)> <!ELEMENT lastName (#PCDATA)> <!ELEMENT city (#PCDATA)>
15) Explain steps to apply DTD to an XML?
The below steps need to be performed to apply DTD to an XML Document
- Create a DTD File with element and attributes
- Provide the DTD Definition in the XML Document
- Provide the reference of DTD file in the XML Document
16) What is XSL ?
- XSL stands for Extensible Stylesheet Language
- XSL provides stylesheet which helps in displaying XML data in a specific format
17) What is XSLT ?
- XSLT stands for Extensible Stylesheet Language Transformations
- XSLT is the recommended stylesheet language for XML
- XSLT used XPath for traversing the XML Document
- XSLT allows to add or remove XML elements and attribute based on user requirement
- XSLT allow to rearrange , hide and sort XML elements and attributes
18) What is XQuery in XML ?
XQuery is a W3C recommendation. XQuery in XML is similar to SQL for Database which allows to query the XML data using the built-n XPath expression
XQuery can be used to transform XML data to HTML, helps in generating reports, passing requested data to Web Service, etc.
for $x in doc("store.xml")/onlinestore/clothes
where $x/price>70
order by $x/brand
return $x/brand19) What is XLink in XML ?
XLink is a W3C recommendation and is useful when we need to create hyperlinks in the XML Document for any existing XML element
<?xml version="1.0" encoding="UTF-8"?> <sitepage xmlns:xlink="http://www.planforexams.com/2021/xlink"> <sitepage xlink:type="simple" xlink:href="http://www.planforexams.com">Planforexams.com -Online Exam Preparation Site</homepage> </sitepage>
20) What is an XML schema ?
XML Schema is an alternate to DTD which describes the structure of XML Document. An XML Document with correct syntax, validated against the XML schema is termed as “Well Formed” and “Valid”
<xs:element name="address"> <xs:complexType> <xs:sequence> <xs:element name="firstName" type="xs:string"/> <xs:element name="lastName" type="xs:string"/> <xs:element name="city" type="xs:string"/> <xs:element name="state" type="xs:string"/> <xs:element name="country" type="xs:string"/> </xs:sequence> </xs:complexType> </xs:element>
21) Can XML files be viewed in browsers?
Yes, XML files are supported by all browsers but it does not display as HTML Pages
22) Difference between a simple element and complex type in XML ?
Simple Element:
- Simple elements in XML are text-based elements.
- Simple element does not hold much attributes but can contain child element.
- Simple element cannot be empty
Complex Type:
- A Complex Type is a combination of multiple elements and attributes
- A Complex Type supports sub-elements among elements
- A Complex Type supports empty element
23) For what purpose diffgram is used in XML ?
Diffgram is an XML format used to identify the current and original XML versions
24) What is XSNL ?
XSNL stands for XML Search Neutral Language which interacts with target system for meta search
25) What is CDATA in XML ?
CDATA is considered as unparsed character data . Thus , when we have the requirement not to get the XML data parsed then we should use CDATA.
The tags inside the CDATA are not treated as markup and thus not parsed
<?xml version="1.0"?> <!DOCTYPE userInfo "user.dtd"> <userInfo> <![CDATA[ <firstName>Mohit</firstName> <lastName>Sharma</lastName> <city>Chandigarh</city> ]]> </userInfo>
26) What is Xpointer in XML ?
Xpointer in XML allows hyperlinks (created using XLink) to point specific XML data within the XML Document
27) What is XML Data Binding ?
Representing the XML Document as an object in memory is known as XML Data Binding
28) Give an example of XML Encoding error ?
The below given could be considered as XML Encoding error
- Invalid Character in the XML Document
- Unsupported character encoding
29) What are the different XML APIs ?
The XML APIs can be classified as given below:
- Tree-based APIs: DOM Parser compiles the XML Document in a tree like structure.
- Event-based APIs: SAX Parser uses the built -in parsing events to traverse the XML Document
30) what is PCDATA in XML?
PCDATA is considered as parsed character data. XML parsers are used to parse all the text in an XML document. The tags inside the CDATA are treated as markup and thus parsed

Leave a Reply