XML - Interview Questions & Answers
1. What is XML ?
XML, Extensible Markup Language, is an open, text based markup language that provides structural and semantic information to data. XML is a metalanguage that can be used to create other language. It is used to structure and describe data that can be understood by other applications. Using XML, we can separate the user interface from data.
2. What are the features of XML ?
1. XML is a generalized markup language that means one can define his/her own tag sets.
2. A valid XML document contains rules and is self-describing.
3. The rules that are found in DTD allow the documents to be validated.
3. Describe the differences between XML and HTML ?
1. User definable tags
2. Content driven
3. End tags required for well formed documents
4. Quotes required around attributes values
5. Slash required in empty tags HTML :
1. Defined set of tags designed for web display
2. Format driven
3. End tags not required
4. Quotes not required
5. Slash not required
4. 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 (eg 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.
5. What is XML namespace? Why it’s important?
XML namespace are similar to package in Java and used to provide a way to avoid conflict between two xml tags of same name but different sources.
XML namespace is defined using xmlns attribute at top of the XML document and has following syntax xmlns:prefix=’URI’. later that prefix is used along with actual tag in XML documents.
6. Why is XML so popular?
1. It supports Unicode. Therefore documents written in any human language can be communicated. 2. Data structures: records, lists and trees can be represented using XML. 3. Its format describes structure, field names and their specific values too. Its therefore called self-documenting. 4. Its syntax and parsing requirements make the necessary parsing algorithms very simple, efficient, and consistent. 5. It can be used as a document storage and processing format. 6. It is platform-independent.
7. Does XML replace HTML?
No. XML itself does not replace HTML. Instead, it provides an alternative which allows you to define your own set of markup elements. HTML is expected to remain in common use for some time to come, and the current version of HTML is in XML syntax. XML is designed to make the writing of DTDs much simpler than with full SGML.
8. 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
1. <person></person>
2. <person/>
9. 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:
1. Other elements within main element
2. An Attribute
3. text
10. Why is XML extensible?
Extensibility is another attribute of XML. XML is short of "eXtensible Markup Language. This is so because a developer may easily create his own XML syntax for any applications he wishes to use it for. Any other developer, once having learned how to use his own language's XML parsing routines, can use any XML-based format currently available.
Related Links