Friday, May 11, 2012

XML Interview Questions and Answers


XML Interview Questions and Answers

What is XML?
The Extensible Markup Language (XML) is a general-purpose specification for creating custom markup languages.[1] It is classified as an extensible language, because it allows the user to define the mark-up elements. XML’s purpose is to aid information systems in sharing structured data.
What is the version information in XML?
The root element can be preceded by an optional XML declaration element stating what XML version is in use (normally 1.0); it might also contain character encoding and external dependencies information.
What is ROOT element in XML?
XML documents must contain one element that is the parent of all other elements. This element is called the root element.
If XML does not have closing tag will it work?
All XML Elements Must Have a Closing Tag otherwise it will produce error while accessing or parsing.
Is XML case sensitive?
yes it is. XML tags are case sensitive. With XML, the tag is different from the tag .
Opening and closing tags must be written with the same case.
What’s the difference between XML and HTML?
On the surface, XML and HTML look similar. Both use tags (such as or ) and attributes (such as align=”left” or type=”personal”) to add information to the content. In fact, a carefully prepared HTML document can double as an XML document. The difference is that HTML is a well-defined set of elements and attributes. For example, the following is a well-formed XML document, but because it only uses tags that are defined in HTML, it’s also an HTML document:
Message of the Day
There is no message of the day.
Try back tomorrow.
On the other hand, HTML has somewhat looser rules than XML, so some HTML documents are not well-formed XML documents.
Is XML meant to replace HTML?
xml is a portable document structure, which is not really for presentation. XSL or CSS may replace html, but really xml is meant to be a storage medium. It is like asking if databases will replace html.
The one aspect that makes this whole thing blurry is that html and now Xhtml is a subset of xml. It is just used to make documents render in browsers.
Can you explain why your project needed XML?
1. If we having huge datas to be transferred instead of sending all those datas as dataset you can opt xml.
2. XML is easy to parse and it enables a faster accessing of datas.
3. Case sensitiveness is an additional advantage in validating the authentication for the user.
4. XML can be passed irrespective of OS, port and protocol.
What is DTD (Document Type definition)?
A Document Type Definition (DTD) defines the legal building blocks of an XML document. It defines the document structure with a list of legal elements and attributes.
A DTD can be declared inline inside an XML document, or as an external reference
Although XML allows you to invent as many different elements and attributes as you need, these elements and attributes, as well as their contents and the documents that contain them, must all follow certain rules in order to be well-formed. If a document is not well-formed, any attempts to read it or render it will fail.
What is a valid XML?
XML that meets the constraints defined by its Document Type Declaration.
What is CDATA section in XML?
CDATA Sections are used to escape blocks of text containing characters which would otherwise be recognized as markup. All tags and entity references are ignored by an XML processor that treats them just like any character data. CDATA blocks have been provided as a convenience measure when you want to include large blocks of special characters as character data, but you do not want to have to use entity references all the time
What is XSL?
Extensible Style Language is a style sheet language aimed at activities such as rearranging the document that are not supported by CSS, though XSL and CSS share the same underlying concepts. XSL can be used to style XML documents u sing sets of rules and definitions of actions to be applied. XSL is a specification from the W3C.
What is Element and attributes in XML?
The basic building blocks of XML Schemas are elements and attributes. Data types define the valid content that elements and attributes contain. When you create XML Schemas, you define the individual elements and attributes and assign valid types to them. Elements describe data, whereas attributes are like properties of an element, in that they provide further definition about the element the way that properties describe characteristics of objects and classes.
An element describes the data that it contains. Elements can also contain other elements and attributes.
An attribute is a named simple-type definition that cannot contain other elements. Attributes can also be assigned an optional default value and they must appear at the bottom of complex-type definitions. Additionally, if multiple attributes are declared, they may occur in any order.
What are the standard ways of parsing XML document?
DOM and SAX parsers are the standard ways for parsing XML document.
In What scenarios will you use a DOM parser and SAX parser?
In some scenarios, SAX is easily the better choice for quick, less-intensive parsing and processing. In others, the DOM provides an easy-to-use, clean interface to data in a desirable format. You, the developer, must always analyze your application and its purpose to make the correct decision as to which method to use, or how to use both in concert.
What is XSLT?
Extensible Stylesheet Language Transformations. A programming language specialized for the transformation of XML documents.
Define XPATH?
A query language used to identify a set of nodes within a XML document. Originally defined to be used with XSLT, it is also used by XPointer and a simple subset is used in the xs:key, xs:keyref, and xs:unique W3C XML Schema elements. The XQuery specification will be a superset of the second version of XPath. This version will use type information provided by W3C XML Schema
What is an XMLReader Class?
Represents a reader that provides fast, non-cached, forward-only access to XML data.
XmlReader provides forward-only, read-only access to a stream of XML data. The XmlReader class conforms to the W3C Extensible Markup Language (XML) 1.0 and the Namespaces in XML recommendations.
What is XMLTextReader?
The XmlTextReader class requires fast access to XML data. It does not require reading the entire document into memory via the Document Object Model (DOM). The class is derived from the XmlReader class and implements all the methods defined in the XmlReader class. The following are the functions of the XmlTextReader class:
* It enforces rules of a well-formed XML document.
* It does not provide any data validation in a document.
* It checks the Document Type Definition (DTD) and DocumentType nodes for their well-formed structure, but does not validate these nodes by using the DTD.
How do we access attributes using “XmlReader”?
The XmlReader class provides various methods and properties for reading attributes. Attributes are most commonly found on elements. However, they are also allowed on XML declaration and document type nodes.
When positioned on an element node, the MoveToAttribute methods enable you to go through the attribute list of the element. After MoveToAttribute has been called, the node properties—such as Name, NamespaceURI, Prefix, and so on—reflect the properties of that attribute, and not the containing element it belongs to.
What does XmlValidatingReader class do?
Represents a reader that provides document type definition (DTD), XML-Data Reduced (XDR) schema, and XML Schema definition language (XSD) validation.
XmlValidatingReader implements the XmlReader class and provides support for data validation. Use the Schemas property to have the reader validate by using schema files that are cached in an XmlSchemaCollection. The ValidationType property specifies what type of validation the reader should perform. Setting the property to ValidationType.None creates a non-validating reader.

0 comments:

Post a Comment