The largest Interview Solution Library on the web

Interview Questions
« Previous | 0 | 1 | 2 | 3 | 4 | Next »

1.How can name conflicts be avoided in XML?

XML allows the user to create their own tags this can lead to conflicts if an attempt is made to mix two different XML documents from different XML applications. In order to avoid this XML uses the concept of namespaces. Which simply uses a prefix to differentiate between two similarly named tags.

<name>Coffee Table</name>
In the above case if both the xml code was to be clubbed together there would be a naming conflict as both the tags of name consists of different content and meaning. In order to avoid this the user simply has to use namespaces.
ie the above code can be re written as:
<b:name>Coffee Table</b:name>
In this way no conflicts occur.

2.In XML how can the user create code which contains content that would be ignored by the parser?

Generally an xml parser would parse through all the text in an XML document. When the parser parses through an xml element all the text between the tags is also parsed. The parser has been programmed to do so as a tag may contain more tags inside it. In case the user wants to specify any content that he does not want the parser to parse he can use the property of CDATA. Everything that a user specifies within a cdata section would be ignored by the parser.
The syntax for CDATA section:
<![CDATA[" and ends with "]]>
Some of the restrictions of the cdata section are:
- A cdata section cannot contain the string “]]>”.
- CDATA section nesting is not allowed.

3.How are documents accessed and manipulated in XML?

The XML DOM (document object model) is used the access and management of xml. It is a platform that is language neutral and allows a program or a script to dynamically access a document. It also allows the updation of content as well as the structure and style of the document. It is responsible for the defining of the object and properties of all xml elements as well as to define the methods for their access.
There are various methods that can be used in xml dom such as:

  • getElementsByTagName : Used to call a specific user defined tag.
  • setAttribute : Used to change the value of an existing attribute.
  • appendChild : Used to add a child node to another node.

4.Write a code for XML news?

The xml news is a specification that is used for the exchange of information and news. An example of an XML news document is as follows:
<?xml version="1.0" encoding="ISO-8859-1"?>
<title>Natural Disaster</title>
<hl1>143 Dead in Natural Disaster</hl1>
<bytag>By Bob Roy, News Line Press</bytag>
<location>Lonely Planet</location>
<date>Monday January 12 2012 9:13 ET</date>

5.How are white-spaces handled by xml?

Any white-space ( this includes line breaks, tab characters and normal spaces etc.) are passed by the xml parser unchanged to an application. This implies that it is not the responsibility of a parser on how to interpret a white-space, instead it is the responsibility of the application to know what to do with it. The white-spaces in xml can be broadly categorized into two types:

  • Insignificant white-space : Those whites-paces that are found between structural elements and are passed by the parser as they are to the application without any effect ( suppressed) are the insignificant spaces. A good example of such white-spaces are the spaces given in an html document.
  • Significant white-space : Those spaces that occur between the elements and can contain text and markup mixed together and are passed by the parse exactly the way they are to the application for their handling are known as the significant white-spaces.

6.What is E4X in reference to XML?

The E4X is a java script standard that is officially released by them. It extends the direct support of xml in java scripts. It allows the user to declare a xml variable in the same way an array is declared.
For Example:
var x = new XML()
var employees=

document.write(employees.person.(name == "Tove").age);
The E4X on being used by the user greatly reduces the amount of code that has to be written to execute an operation.

7.How is metadata handled by xml?

The xml does not contain any predefined elements. Xml generally in broad terms is considered to be an architecture and not an application. Due to this reason it is not the responsibility of xml to specify how metadata is to be implemented. It is left up to the user to select how to implement metadata. Most browsers have their own way of specifying a method to handle metadata. The xml metadata interchange is used as a standard way for users to exchange information pertaining to metadata. The metadata information is usually stored in the form of attributes.

For Example:
<note id="501">
<body>Don't forget me this weekend!</body>
<note id="502">
<heading>Re: Reminder</heading>
<body>I will not</body>
In the above code the id is used to identify different xml elements, this is also a form of metadata.

8.While writing an xml document what are the rules that are to be followed?

Since xml does not have any predefined tags or elements there are not much problems in writing an xml document. Although there are a few rules that should be kept in mind while writing the document such as:
- The tags in xml once opened should also must be closed.
- All the tags in xml are case sensitive.
- All xml elements must be properly nested.

For Example:
<home> <room> …. …. </room> </home>
The entire document must contain a root node which would contain all the tags defined in the document within it.
- Any attribute values must be specified between quotes.

9.What do you understand by SVG and SMIL? Give examples

The SVG and SMIL are xml languages that are specifically used for multimedia purposes.

  • SVG (scalable vector graphics) : This language enables the user to display 2 dimensional vector graphic images and animations from the xml code. It makes use of the vector mathematical formulas to render the content.
  • SMIL (synchronized multimedia integration language) : This language is used to integrate text , images and other media together for a presentation.
For Example : A simple svg example:
<svg xmlns=""
<rect x="10" y="10" height="100" width="100"
style="stroke:#ff0000; fill: #0000ff"/>

10.What is the role of the doctype declaration in reference to XML?

The doctype has several purposes in an xml document such as:

  • It is used for validation purposes of the document.
  • It helps the browser to tell which version of the markup language was used by the creator.
  • The doctype helps in rendering a page properly in a browser that is standards compliant.
The doctypes can be differentiated into three major types:

strict doctype declaration : This declaration is used when css is being used to style a page.
transactional doctype declaration : This doctype specification is used if the document consists of any presentational markups.
frames doctype declaration : This is used id the document is present in form of frames.

11.XML - What is XML?

XML - XML, Extensible Markup Language, is an open, text based markup language that provides structural and semantic information to data......

12.XML document - List the rules to be followed by an XML document.?

XML document - They must have a root tag, the document should be well formed : the tags should be properly closed, since XML is case sensitive, one should take care.....

13.XML DTD - Define DTD (Document Type definition).

XML DTD is a rule book that an XML document follows. Once DTD is ready, you can create number of XML documents following the same rules......

14.How do I create my own document type?

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.

15.How does XML handle metadata?

XML doesn’t have pre-defined elements as it is not an application, but an architecture which doesn’t verify the way the implementation of metadata being used. XML allows you to choose a suitable method to handle XML contents and its metadata information. XML also allows you to define your own markup language in which you can incorporate the extended hypertext features.

16.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[markup]]>

17.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.

18.What is Document Type Definition (DTD)?

DTD is known as Document Type Definition, which provides a description of a document written in XML. DTD consists of XML declaration syntax. It also defines the naming convention rules for different types of element. If you want to describe the lists consisting of some items then DTD will look like:

<!ELEMENT List (Item)+> // Element list contains one or more items (+)
<!ELEMENT Item (#PCDATA)> // element types contains plain text (Parsed Character Data or PCDATA).

19.How can I use XML?

To use XML the requirement is to have a compatible browser that has the support of XML. You can use any browser which supports XML components or XML language. XML is just a file which gets created when you open any website on your browser. It saves your data information and allows the server and the client system to converse with each other. XML files are created with an extension of .xml.

20.How can I read an XML file?

You can use a web browser that supports XML format to open the XML file. If your file is a valid XML file then it will open in any XML supported web browser, if it is not a valid file then it will show an error and web browser won’t display the content of the file. Web browser will show the file in an unformatted way that may become hardly readable. If the file consists of CSS style sheet link, then browser will show the file in a formatted way which can be readable.

« Previous | 0 | 1 | 2 | 3 | 4 | Next »

copyright © 2014 - all rights riserved by