XML Interview Questions :-
What is a markup language?
Markup languages are designed for presentation of text in different formats, and it can also be used for transporting and storing data. This markup language specifies the code for formatting, layout and style of data .This markup code is called Tag.
HTML and XML are examples of Markup Language.
What is XML?
XML is called Extensible Markup Language which is designed to carry or transport and store data. XML tags are not as predefined as HTML, but we can define our own user tags for simplicity.
It mainly concentrates on storing of data, not on displaying of data.
What is the difference between XML and HTML?
XML is no way clashes with HTML, since they are many differences between HTML and XML :-
1. HTML is for displaying purpose.
2. HTML is used to mark up text so it can be displayed to users.
3. HTML describes both structure (e.g. <p>, <h2>, <em>) and appearance (e.g. <br>, <font>, <i>)
4. HTML uses a fixed, unchangeable set of tags.
1. Whereas XML is for data representation.
2. XML is used to mark up data so it can be processed by computers.
3. XML describes only content, or "meaning".
4. In XML, you make up your own tags.
What is a well-formed XML document?
If a document is syntactically correct it can be called as well-formed XML documents. A well-formed document conforms to XML's basic rules of syntax :-
1. Every open tag must be closed.
2. The open tag must exactly match the closing tag: XML is case-sensitive.
3. All elements must be embedded within a single root element.
4. Child tags must be closed before parent tags.
5. A well-formed document has correct XML tag syntax, but the elements might be invalid for the specified document type.
What is a Processing Instruction in XML?
A ProcessingIntruction is the information which we would like to give to application. Through a ProcessingInstruction an application would get idea about how to process the document. A ProcessingInstruction can appear anywhere and any no. of times in a document.
What is DTD?
A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines rules for a specific type of document, including :-
1. Names of elements, and how and where they can be used.
2. The order of elements.
3. Proper nesting and containment of elements.
4. Element attributes.
To apply a DTD to an XML document, you can :-
1. Include the DTD's element definitions within the XML document itself.
2. Provide the DTD as a separate file, whose name you reference in the XML document.
What are the features of XML?
Main features of XML are :-
1. Very easy to learn and implement.
2. Minimal and a limited number of syntax rules in XML.
3. It is extensible, and it specifies that structural rules of tags.
What is XPath?
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.
How does XML handle white-space in my documents?
The white spaces are passed by the parser to the application. It includes the following elements: line-break, Tab, normal space. Parser then identifies the context in which the white spaces was found and send it to the application for further processing
Parser informs the application that, white space has occurred in element content. Application, after receiving the information decides which type of white space to discard and which to retain.
When should I use a CDATA Marked Section?
CDATA is used to let an author to quote fragments of text, containing markup characters. CDATA is not used to preserve embedded markup characters. You use it when you want to design according to your need, like writing documentation etc.
For example :-
"Text to write here"<![CDATA[<em>markup</em>]]>
How does XML handle metadata?
You can create your own document type by incorporating DTD or Schema. DTD and Schema is used with an XML editor that guide and control the construction of document.
To create your own document type, analysis of class documents are required such as: reports, invoices, letter etc. Once the structure is set then the document type can be written according to your requirements.
What is an attribute?
An attribute provides more or additional information about an element than otherwise.
For Example :- <company name="GPS"></company>
What is a Complex Element?
A complex element is an XML element that contains other elements and/or attributes.
There are four kinds of complex elements :-
1. empty elements.
2. elements that contain only other elements.
3. elements that contain only text.
4. elements that contain both other elements and text.
What are the basic rules while writing XML?
1. All XML should have a root element.
2. All tags should be closed.
3. XML tags are case sensitive.
4. All tags should be nested properly.
5. Tag names cannot contain spaces.
6. Attribute value should appear within quotes.
7. White space is preserved.
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.
How does the XML structure is defined?
XML document will have a structure which has to be defined before we can create the documents and work with them. The structural rules can be defined using many available technologies, but the following are popular way of doing so :-
1. Document Type Definition (DTD).
What is the version information in XML?
"Version" tag shows which version of XML is used
Is XML case sensitive?
Yes, XML is case sensitive.
If XML does not have closing tag will it work?
No, every tag in XML, which is opened, should have a closing tag.
Explain different types of XML Application Programming Interface (API).
The following are two main types of XML parsers :-
1. Tree-based API :- Compiles an XML document into a tree structure and loads it into memory. You can traverse and change the tree structure. The DOM is an example of a tree-based API.
2. Event-based API :- Provides the report to an application about the parsing events by a set of built-in callback functions. An example of the event-based API is SAX.
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.
What is a Simple Element?
A simple element is an XML element that can contain only text.
1. A simple element cannot have attributes.
2. A simple element cannot contain other elements.
3. A simple element cannot be empty.
4. However, the text can be of many different types, and may have various restrictions applied to it.
What is the relevance of ElementFormDefault attribute in the Schema?
ElementFormDefault indicates whether or not locally declared elements must be qualified by the target namespace in an instance document. ElementFormDefault attribute in the Schema has the following relevance :-
1. Qualified :- Each and every element of the Schema must be qualified with the namespace in the instance document.
2. Unqualified :- means only globally declared elements must be qualified with there namespace and not the local elements.
Describe the XmlWriter class.
The XmlWriter class is used to write XML to a stream, a file, or a Textwriter object. This class works in a forward-only, non-cached manner. You can configure the XmlWriter object up to a large extent. With this object, you can specify a few things, such as whether to indent content or not, the amount to indent, what quote character to use in attribute values, and whether or not namespaces are supported.
Describe the role that XSL can play while dynamically generating HTML pages from a relational database.
The SQLXML 3.0 and advanced versions provide the facility of mapping the SQL queries output with XSLT templates. It uses XSLT to present the records that are retrieved from databases on Web pages (HTML pages).
An application can use XSLT to modify the output that is retrieved from data sources and display the output by XSL templates. The XSLT displays data without affecting the database query and the code of application.
Which classes are supported to make an XML DOM?
The following are the different classes in the System.Xml namespace that make up the XML DOM :-
1. The XmlNode class.
2. The XmlDocument Class.
3. The XmlElement Class.
4. The XmlAttribute Class.
4. The XmlText class.
5. The XmlComment class.
6. The XmlNodeList Class.
What is XSLT?
XSLT is Extensible Stylesheet Language Transformations that is a part of XML, which is a mechanism to transform an XML document into another XML or HTML document.
Which class is used to encode and decode XML names and contains different methods to convert between CLR types and XSD types.
Why XML has been used for development?
XML is used for development for following reasons :-
1. Used for Database driven websites.
2. Used to store data for e-commerce websites
3. Used to transport and store data on internet.
4. XML is used for database and flat files.
5. Generate dynamic content by applying different style sheets.
What is SGML?
SGML is large and powerful Standard Generalized markup Language which is used to define descriptions of the structure of different types of electronic document.
What are the special characters used in XML?
<, > and and are the special characters used in XML. Because these characters are used for making tags.
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.
What is XSL-FO?
XSL-FO deals with formatting XML data. This can be used for generating output in a particular format like XML to PDF, XML to DOC, etc.
What is SAX?
SAX-Simple API for XML processing. SAX provides a mechanism for reading data from an XML document. It is a popular alternative to the Document Object Model (DOM).SAX provides an event based processing approach unlike DOM which is tree based.
What are the interfaces of SAX?
The interfaces of SAX are :-
1. DocumentHandler :- is used for getting event notification relating to a document.
2. DTDHandler :- is implemented to get the notifications related to declarations in DTD like entities and notations.
3. EntityResolver :- is used for reading external entities.
ErrorHandler :- is used for handling error related notifications.
What is XQuery?
Xquery is a query language that is used to retrieve data from XML documents. You can add, update, delete and list the XML with use of XQuery.
What is XMLA ?
It is protocol of Microsoft for XML-messaging used for exchanging data between client and servers.
What is SOAP?
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.