XML Interview Questions and Answers

1. What Is Xml?
XML is the Extensible Markup Language. It improves the functionality of the Web by letting you identify your information in a more accurate, flexible, and adaptable way.
It is extensible because it is not a fixed format like HTML (which is a single, predefined markup language). Instead, XML is actually a metalanguage—a language for describing other languages— which lets you design your own markup languages for limitless different types of documents. XML can do this because it’s written in SGML, the international standard metalanguage for text document markup (ISO 8879).

2. What is the meaning of the version in XML?
Version is a tag used to show which version of XML is used.
Declaring the XML version is very important for each XML document and platform needs to be specified in which it is running.

<?xml version=”1.1” encoding=”|ISO-8859-1|”?>

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

<?xml version=”1.0”/>

4. If XML attribute name itself has double quotes, then how it can be represented?
Attribute name can be represented within single quotes if double quotes are present in the attribute name.
Example –

<country city='Texas "US"'></country>

5. Define Structure of XML?

structure of xml

6. Is XML meant to be a replacement of HTML?
No, the two languages have their own specifications and are used for various purposes. XML is used to describe data but while HTML focuses on displaying data.

7. Why XML has been used for development?
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

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

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

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

11. List some features of XML?
XML or the Extensible Markup Language has some amazing features that are easy when it comes to implementation and learning. Some of the remarkable ones are:
• The XML files require no editors, as they are text-only.
• When it comes to Syntax rules, XML has only a few of them.
• The language is known for being extensible which specifies the tags’ structural rules.

12. State some benefits of XML?
The key benefits of using XML are those.
Simplicity: The knowledge stored in XML is really simple to read and understand.
Openness: It is a W3C standard which is endorsed by market leaders in the software industry.
Extensibility: Extensible because it doesn’t have a fixed set of tags. You can describe them however you like.
Self-descriptive: XML documents do not require unique schema configurations to store data like traditional databases. Without these concepts XML documents may be processed as they include metadata in the form of tags and attributes.
Scalable: XML is not in binary format so that you can create and edit files with anything, and debugger is easy too.
Fast access: XML documents are hierarchically arranged and it’s comparatively easier.

13. What are the disadvantages of using XML?
Following are the disadvantages of XML usage −
• Redundant Syntax – Normally XML file contains lot of repetitive terms.
• Verbose – Being a verbose language, XML file size increases the transmission and storage costs.
• XML will be just a text file if elements and attributes are not defined properly.
• Overlapping markup is not permitted

14. Define the basic XML rules?
There are certain rules that every XML developer has to follow such as:
• The root element is a must for XML
• The tags must be all closed
• The tags of XML are case-sensitive
• Proper nesting of tags
• There should be no space between tag names
• All the attributed values must be quoted

15. Whether root element is required for XML? If so, how many root elements are required?
Yes, root element is required, and it can have only one root element in each XML.

16. What Is A Markup Language?
A markup language is a set of words and symbols for describing the identity of pieces of a document (for example ‘this is a paragraph’, ‘this is a heading’, ‘this is a list’, ‘this is the caption of this figure’, etc). Programs can use this with a style sheet to create output for screen, print, audio, video, Braille, etc.
Some markup languages (e.g. those used in word processors) only describe appearances (‘this is italics’, ‘this is bold’), but this method can only be used for display, and is not normally re-usable for anything else.

17. Why Is Xml Such An Important Development?
It removes two constraints which were holding back Web developments:
1. Dependence on a single, inflexible document type (HTML) which was being much abused for tasks it was never designed for;
2. The complexity of full SGML, whose syntax allows many powerful but hard-to-program options. XML allows the flexible development of user-defined document types. It provides a robust, nonproprietary, persistent, and verifiable file format for the storage and transmission of text and data both on and off the Web; and it removes the more complex options of SGML, making it easier to program for.

18. What is XML Parsing?
Parsing XML refers to going through XML document to access data or to modify data in one or other way.

19. When to use a DOM Parser?
You should use a DOM parser when –
• You need to know a lot about the structure of a document
• You need to move parts of the document around (you might want to sort certain elements, for example)
• You need to use the information in the document more than once

20. What are the key components/interfaces of DOM Parsing?
The DOM defines several Java interfaces. Here are the most common interfaces −
Node – The base datatype of the DOM.
Element – The vast majority of the objects you’ll deal with are Elements.
Attr – Represents an attribute of an element.
Text – The actual content of an Element or Attr.
Document – Represents the entire XML document. A Document object is often referred to as a DOM tree.

21. How to connect XML with the database?
XML import and export modules are used to connect XML applications with databases. There has to be a 1:1 match between the field name of element type and the database table in DTD or XML schema. While in some cases little programming is required to establish the desired match.

22. Who is responsible for XML?
XML is a project of the World Wide Web Consortium (W3C), and the development of the specification is supervised by an XML Working Group. A Special Interest Group of co-opted contributors and experts from various fields contributed comments and reviews by email.
XML is a public format: it is not a proprietary development of any company, although the membership of the WG and the SIG represented companies as well as research and academic institutions. The v1.0 specification was accepted by the W3C as a Recommendation on Feb 10, 1998.

23. What is well formed XML document?
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

24. Define XSL?
To express style sheets in XML, XSL is used. It is a language that helps you with XML document display.

25. Describe The Role That Xsl Can Play When Dynamically Generating Html Pages From A Relational Database?
Even if candidates have never participated in a project involving this type of architecture, they should recognize it as one of the common uses of XML. Querying a database and then formatting the result set so that it can be validated as an XML document allows developers to translate the data into an HTML table using XSLT rules. Consequently, the format of the resulting HTML table can be modified without changing the database query or application code since the document rendering logic is isolated to the XSLT rules.

26. Define the three parts of XSL?
There are a total of 3 parts for XSL:
• XSLT – It is required for the transformation of the document
• XPath – It is required for XML document navigation
• XSL-FO – It is required for XML document formatting

27. What is XSLT?
XSLT is a common XML technology that converts one XML file into another document, such as HTML etc. XSLT is like a language for the transformation of XML documents that has its own syntax, functions and operator. XSLT is often known as the HTML pages for viewing data present in XML files.

28. Why XSLT is important for XML?
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.

29. What is XQuery?
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.

30. What is XPath in XML?
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.

31. What is an attribute?
An attribute provides more or additional information about an element than otherwise.
Example –

<Person name=”Peter”>

32. Can we have empty XML tags?
Yes, we can have empty tags in XML. Empty tags are used to indicate elements that have no textual content. Empty tags can be represented as



33. What is XML DOM Document?
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.

34. What are the advantages of XML DOM Document?
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

35. What is XML Element?
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

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

37. What Is SGML?
SGML is the Standard Generalized Markup Language (ISO 8879:1986), the international standard for defining descriptions of the structure of different types of electronic document. It is both powerful and large.

38. Aren’t XML, SGML, And HTML All The Same Thing?
Not quite; SGML is the mother tongue, and has been used for describing thousands of different document types in many fields of human activity, from transcriptions of ancient Irish manuscripts to the technical documentation for stealth bombers, and from patients’ clinical records to musical notation. SGML is very large and complex, however, and probably overkill for most common office desktop applications.
XML is an abbreviated version of SGML, to make it easier to use over the Web, easier for you to define your own document types, and easier for programmers to write programs to handle them. It omits all the complex and less-used options of SGML in return for the benefits of being easier to write applications for, easier to understand, and more suited to delivery and interoperability over the Web. But it is still SGML, and XML files may still be processed in the same way as any other SGML file (see the on XML software).
HTML is just one of many SGML or XML applications—the one most frequently used on the Web. Technical readers may find it more useful to think of XML as being SGML– rather than HTML++.

39. How XML is different from HTML?
HTML stands for the Hyper Text Markup Language, while XML stands for the markup language eXtensible. Here are the main distinctions between HTML and XML:
1. HTML is used to display data and to focus on the look of the data. XML is an independent software and hardware tool used for the data transmission and storage. It focuses on what defines data.
2. HTML itself is a markup language. XML offers a basis for specifying languages for the markup.
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.

40. Give A Few Examples Of Types Of Applications That Can Benefit From Using Xml?
There are literally thousands of applications that can benefit from XML technologies. The point of this is not to have the candidate rattle off a laundry list of projects that they have worked on, but, rather, to allow the candidate to explain the rationale for choosing XML by citing a few real world examples. For instance, one appropriate answer is that XML allows content management systems to store documents independently of their format, which thereby reduces data redundancy. Another answer relates to B2B exchanges or supply chain management systems. In these instances, XML provides a mechanism for multiple companies to exchange data according to an agreed upon set of rules. A third common response involves wireless applications that require WML to render data on hand held devices.

41. What Is Dom And How Does It Relate To Xml?
The Document Object Model (DOM) is an interface specification maintained by the W3C DOM Workgroup that defines an application independent mechanism to access, parse, or update XML data. In simple terms it is a hierarchical model that allows developers to manipulate XML documents easily Any developer that has worked extensively with XML should be able to discuss the concept and use of DOM objects freely. Additionally, it is not unreasonable to expect advanced candidates to thoroughly understand its internal workings and be able to explain how DOM differs from an event-based interface like SAX.

42. What Is Soap And How Does It Relate To Xml?
The Simple Object Access Protocol (SOAP) uses XML to define a protocol for the exchange of information in distributed computing environments. SOAP consists of three components: an envelope, a set of encoding rules, and a convention for representing remote procedure calls. Unless experience with SOAP is a direct requirement for the open position, knowing the specifics of the protocol, or how it can be used in conjunction with HTTP, is not as important as identifying it as a natural application of XML

43. Why Not Just Carry On Extending Html?
HTML was already overburdened with dozens of interesting but incompatible inventions from different manufacturers, because it provides only one way of describing your information.
XML allows groups of people or organizations to C.13, create their own customized markup applications for exchanging information in their domain (music, chemistry, electronics, hill-walking, finance, surfing, petroleum geology, linguistics, cooking, knitting, stellar cartography, history, engineering, rabbit-keeping, C.19, mathematics, genealogy, etc).
HTML is now well beyond the limit of its usefulness as a way of describing information, and while it will continue to play an important role for the content it currently represents, many new applications require a more robust and flexible infrastructure.

44. Why Should I Use Xml?
Here are a few reasons for using XML .
• XML can be used to describe and identify information accurately and unambiguously, in a way that computers can be programmed to ‘understand’ (well, at least manipulate as if they could understand).
• XML allows documents which are all the same type to be created consistently and without structural errors, because it provides a standardised way of describing, controlling, or allowing/disallowing particular types of document structure. [Note that this has absolutely nothing whatever to do with formatting, appearance, or the actual text content of your documents, only the structure of them].
• XML provides a robust and durable format for information storage and transmission. Robust because it is based on a proven standard, and can thus be tested and verified; durable because it uses plain-text file formats which will outlast proprietary binary ones.
• XML provides a common syntax for messaging systems for the exchange of information between applications. Previously, each messaging system had its own format and all were different, which made inter-system messaging unnecessarily messy, complex, and expensive. If everyone uses the same syntax it makes writing these systems much faster and more reliable.
• XML is free. Not just free of charge (free as in beer) but free of legal encumbrances (free as in speech). It doesn’t belong to anyone, so it can’t be hijacked or pirated. And you don’t have to pay a fee to use it (you can of course choose to use commercial software to deal with it, for lots of good reasons, but you don’t pay for XML itself).
• XML information can be manipulated programmatically (under machine control), so XML documents can be pieced together from disparate sources, or taken apart and re-used in different ways. They can be converted into almost any other format with no loss of information.
• XML lets you separate form from content. Your XML file contains your document information (text, data) and identifies its structure: your formatting and other processing needs are identified separately in a stylesheet or processing system. The two are combined at output time to apply the required formatting to the text or data identified by its structure (location, position, rank, order, or whatever).

45. Can You Walk Us Through The Steps Necessary To Parse Xml Documents?
Superficially, this is a fairly basic . However, the point is not to determine whether candidates understand the concept of a parser but rather have them walk through the process of parsing XML documents step-by-step. Determining whether a non-validating or validating parser is needed, choosing the appropriate parser, and handling errors are all important aspects to this process that should be included in the candidate’s response.

46. Give Some Examples Of XML DTDs Or Schemas That You Have Worked With?
Although XML does not require data to be validated against a DTD, many of the benefits of using the technology are derived from being able to validate XML documents against business or technical architecture rules. Polling for the list of DTDs that developers have worked with provides insight to their general exposure to the technology. The ideal candidate will have knowledge of several of the commonly used DTDs such as FpML, DocBook, HRML, and RDF, as well as experience designing a custom DTD for a particular project where no standard existed.

47. What is the difference between XML DTD and XML schema or XSD?
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.

1) DTD stands for Document Type Definition. XSD stands for XML Schema Definition.
2) DTDs are derived from SGML syntax. XSDs are written in XML.
3) DTD doesn’t support datatypes. XSD supports datatypes for elements and attributes.
4) DTD doesn’t support namespace. XSD supports namespace.
5) DTD doesn’t define order for child elements. XSD defines order for child elements.
6) DTD is not extensible. XSD is extensible.
7) DTD is not simple to learn. XSD is simple to learn because you don’t need to learn new language.
8) DTD provides less control on XML structure. XSD provides more control on XML structure.

48. Using XSLT, How Would You Extract A Specific Attribute From An Element In An Xml Document?
Successful candidates should recognize this as one of the most basic applications of XSLT. If they are not able to construct a reply similar to the example below, they should at least be able to identify the components necessary for this operation: xsl:template to match the appropriate XML element, xsl:value-of to select the attribute value, and the optional xsl:apply-templates to continue processing the document.
Extract Attributes from XML Data

<xsl:template match="element-name">
Attribute Value:
<xsl:value-of select="@attribute"/>

49. When Constructing An Xml Dtd, How Do You Create An External Entity Reference In An Attribute Value?
Every interview session should have at least one trick . Although possible when using SGML, XML DTDs don’t support defining external entity references in attribute values. It’s more important for the candidate to respond to this in a logical way than the candidate know the some what obscure answer.

50. Is there a way to describe XML data?
Yes, XML uses Document Type Definition (DTD) to describe the data.

Sign-up for our email newsletter and get free job alerts, current affairs and GK updates regularly.
Subscribe Here (or)

Leave a Reply

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

four × = 16

Popup Dialog Box Powered By : XYZScripts.com
  • RSS
  • Facebook
  • Google+
  • Twitter