Planforexams.com

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

3) Describe well-formed XML document?

The well formed XML documents should have features

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):

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.

8) Explain XML HttpRequest ?

The XML HttRequest is :

9) Explain XML Parser ?

The XML Parser is :

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:
Jeans

10) 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 ?

XMLHTML
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 tagsHTML provides built-in tags
A well formed XML should have the closing tagClosing tags are not mandatory in HTML
XML is dynamic HTML is static
XML preserves whitespacesHTML does not preserve whitespaces
XML vs HTML

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 ?

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

16) What is XSL ?

17) What is XSLT ?

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/brand

19) 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:

Complex Type:

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

29) What are the different XML APIs ?

The XML APIs can be classified as given below:

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

Exit mobile version