Sei sulla pagina 1di 15

XML Interview Questions with Answers

1.1 1.2 1.3 1.4 XML Subjective Questions with Answers XML Interview Questions with Answers XML Objective Questions And Answers FAQS

Introduction Of XML:

XML (eXtensible Markup Language) is a specification developed by the World Wide Web Consortium (W3C).it is very flexible text format derived from SGML (ISO 8879). Originally designed to meet the challenges of large-scale electronic publishing, XML is also playing an increasingly important role in the exchange of a wide variety of data on the Web and elsewhere. It is a markup language much like HTML used to describe data. In XML, tags are not predefined. A user defines his own tags and XML document structure like Document Type Definition (DTD) , XML Schema to describe the data. Hence it is self-descriptive too .There is Nothing Special About XML It is just plain text with the addition of some XML tags enclosed in angle brackets. In a simple text editor, the XML document is easily visible . Document Type Definition :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. XML Schema :XML Schema is an XML-based alternative to DTDs. It describes the structure of an XML document. The XML Schema language is also referred to as XML Schema Definition (XSD). "Well Formed" :XML document is a document that conforms to the XML syntax rules.

"Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD) History Of XML: XML was developed to overcome the shortcomings of its two predecessors, HTML and SGML which were both very successful markup languages, but which were both restricted in certain ways. SGML, the international standard for marking up data, has been used since the 1980's. SGML is an extremely powerful and extensible tool for semantic markup which is particularly useful for cataloging and indexing data. Like XML, SGML can be used to create an infinite number of markup languages and has a host of other resources as well. However, SGML is complex, especially for the everyday uses of the web. Moreover, SGML is expensive. Adding SGML capability to a word processor could double or triple the price. Finally, the commercial browsers do not intend to ever support SGML. HTML on the other hand was free, simple and widely supported. HTML was originally designed to provide a very simple version of SGML which could be used by regular people. However, HTML had serious defects. XML So in 1996, discussions began which focused on how to define a markup language with the power and extensibility of SGML but with the simplicity of HTML. The World Wide Web Consortium (W3C) decided to sponsor a group of SGML gurus including Jon Bosak from Sun. Essentially, Bosak and his team did to SGML what the Java team had done to C++. All of the non-essential, unused, cryptic parts of SGML were sliced away. What remained was a lean, mean marking up machine: XML. The specification of XML (written mostly by Tim Bray and C.M. Sperberg-McQueen) was only 26 pages as opposed to the 500+ pages of the SGML specification! Nevertheless, all the useful things which could be done by SGML, could also be done with XML. XML Over the next few years, XML evolved, drawing from the work of its sponsors and the work of developers solving similar problems such as Peter Murray-Rust who had been working on CML (Chemical Markup Language) and the consortium of folks working on MathML. By mid 1997 The eXtensible Linking Language XLL project was underway and by the summer of 1997, Microsoft had launched the Channel Definition Format (CDF) as one of the first realworld applications of XML. Finally, in 1998, the W3C approved Version 1.0 of the XML specification and a new language was born. Why Is XML So Important? There are number of reasons that contributes to the XML's increasing acceptance , few of them are: 1. Plain Text 2. Data Identification

3. 4. 5. 6.

Satiability Universally Processed Hierarchical Approach Inline Reusability

Architecture Of XML:

A basic architecture of an XML application using DOM is presented: In This Figure A parser reads the XML file and builds a DOM document to match the XML file. From that point until a save is performed, all interaction between the application and XML hits the DOM document rather than the corresponding XML file. It interesting to note that almost all XML parsers use SAX. Before you build a DOM document you must detect events such as the start of an element (start tag encountered), end of an element (end tag encountered) and/or a new attribute (name followed by equal sign followed by quoted string encountered). DOM can be thought of as an extra abstraction to lessen the programmer workload, at the expense of memory usage. Modifications are made directly to the DOM document. Elements can be added, deleted, renamed, and rearranged. Text nodes can be added, deleted or changed. Elements can be moved either within the same level, or promoted or demoted to different levels Advantage of XML: 1. It is text-based. 2. It is platform-independent. 3. It manifests as plain text files. 4. Integrating with Existing Data Types 5. Extensibility 6. It supports Unicode (allowing information in any language). 7. It can represent data structures: records, lists and trees. 8. It is based on international standards. 9. The hierarchical structure is suitable for most types of documents. 10. It makes parsing algorithms simple, efficient, and consistent. .

Difference Between Html and XML: 1. XML was designed to describe data and to focus on what data is. HTML was designed to display data and to focus on how data looks . 2. HTML is about displaying information, while XML is about describing information. 3. HTML is presentation language where as XML is not either a programming language or a presentation language. It is used to transfer data between applications and databases. 4. HTML is not case-sensitive where as XML is case-sensitive. 5. In XML it is mandatory to close each and every tag where as in HTML it is not required. 6. In XML, Data is stored in separate XML files but in HTML, it is stored inside the files. 7. White Spaces is preserved in XML files. 8. To display HTML, we used CSS .In XML, we used XSL. Relation Between SGML And XML

XML is a real subset of SGML.The most important diffrence is that output spesification is not defined by SGML, but it is fixed in XML.

Importance Feature Of XML: 1. XML files are text files, which can be managed by any text editor. 2. XML is very simple, because it has less than 10 syntax rules. 3. XML is extensible, because it only specifies the structural rules of tags. No specification on tags them self. Disadvantage 1. 2. 3. 4. 5. 6. 7. Syntax is redundant or large relative to binary representations of similar data The hierarchy schemata can be limiting Syntax is verbose relative to other alternative 'text-based' formats. More difficult, demanding, and precise than HTML It does not support data types, such as 'integer', 'string', 'boolean', and so on. Lack of browser support/end user applications The hierarchical model for representation is limited in comparison to an object oriented model. 8. Namespaces are problematic to use and support

XML Interview Questions And Answers

Page 1
Ques: 1 What is the XML? Explain it. Ans: XML is stands for eXtensible Markup Language.It is invented by World Wide Web Consortium(W3C). Don't Confuse with that HTML and XML are same.For efficient use of XML you should know HTML and JavaScript.I have given you some basic features of XML. 1.It is called extensible because using XML you can create own tags as per requirement. 2.XML is used to communicate and store the data,not to show the data. 3.Using XML we can identify our information in a more accurate, flexible and adaptable way. 4.It is used to make about structural information of data. 5.XML is a Metalanguage(Language use for describing other language.) Ans: XML stand for EXtensible Markup Language. Ques: 2 How we can say XML is differ from HTML? Ans: Both XML(eXtensible Markup Language) and HTML(Hyper Text Markup Language)are markup languages.But they are different.I have given you some main difference b/w XML and HTML given below. 1.The key difference is that XML is used for to store data and made communication b/w them.Where HTML is used to present the data in attractive way. 2.In XML we emphasize on 'what data is'. Where as in HTML we emphasize on 'What data looks like'.

3.In HTML tag semantic and tag set are fixed means that in HTML their is no made our own tags.where as in XML these are not fixed so, can we made our own tags as per requirement. 4.XML is dynamic where as HTML is static. 5.HTML is case sensitive language where as XML is non-case sensitive language. 6.In XML it is mandatory to close all open tags where as in HTML their is not mandatory to close all open tags. Ques: 3 What do you understand about XML Namespaces and Linking? Ans: I have you some information about XML Namespaces and XML Linking. XML Namespaces: XML give as facility to make our own tags. Suppose if we want add element of two XML sheets their may be conflicts. But if we made our own tags than it can solve the problem of data conflicts,because different tags may contain the same type of data. XML Linking: Using XML linking we can create the connection among the XML data means they can communicate each other. XML Linking(XML Link,XML Pointer & XML Base) Where, XML Link is used to insert link into XML Sheets. XML Pointer is used to link the address of some specific data in XML sheets. XML Base is used to defining a default reference to external XML resources. Ques: 4 What do you understand about XPath? Ans: XPath is stands for XML Path Language.That is used to addressed the element of XML Document.In XML document we define our data in terms of tree.It is used to address the element and their attribute at any level.I have given you a example this shows how to address parts of XML. Example: /xyz:Employeedatabase/xyz:Empname/@EmpID Using above we can address the EmpID. Ques: 5 What you define SAX in XML? Ans: SAX is stands for Simple API for XML.It is a lexical and event-driven interface.Implementation of SAX is fast and efficient but we can't extract information from XML at random.It is good for use when some types of information ewe handle in same way always without knowing that where it execute in document. How to use SAX in XML: # Use to get a list of known parsers my $parsers = XML::SAX->parsers(); # Use to add/update a parser XML::SAX->add_parser(q(XML::SAX::PurePerl)); # Use to remove parser XML::SAX->remove_parser(q(XML::SAX::Foodelberry)); # Use to save parsers XML::SAX->save_parsers() Ques: 6 How you define DOM in XML? Ans: DOM is stands for Document Object Model.It is used to represent data in terms of node of tree. It is an interface given by W3C DOM Workgroup used to

access,parse or update XML data.We make DOM document either by parser or manually by user.Data types that we used in DOM Nodes are abstract.DOM also supported java Ques: 7 How SAX is different than DOM? Ans: We use DOM for internal presentation of XML.It is good for small XML file but bad for large files because when we use DOM for large file it present whole filw into the memory.Where SAX is work on perticular event so,it can use to find out the specific element of XML doc.It can not present data of XML.It works from top to bottom in XML file. We can't use SAX without DOM. Ques: 8 How you define XMLA? Ans: XMLA stands for XML Analysis Services.It is designed to generate reports of data that was contained in data warehouse.It does not create relation between the data structure.In XML we Use XMLA to show the analysis service data to outer world. Ques: 9 What is XHTML? Ans: XHTML is stands for eXtensible HTML.It is a combination of HTML4 with XML rules means when we using XHTML than when we open any tag it should has an end tag and we write attribute value with in single quote or double quote. Ques: 10 what do you know about XML parser? Ans: It is a COM component.Microsoft give XML Parser with interner explorer 5 or higher version of internet explorer.After that parser is avail with scripts.XML Parser has many function using them we can traverse the tree,access the nodes with their values.also using them we can insert,delete the nodes and after that it will changed to XML. Using that code we can made the instance of XML Parser with JavaScript. var xmlDoc=new ActiveXObject("Microsoft.XMLDOM") Can made instanceof XML Parser with VBScript set xmlDoc=CreateObject("Microsoft.XMLDOM") Can made instance of XML Parser in anASP page. set xmlDoc=Server.CreateObject("Microsoft.XMLDOM") Using this code we can load the XML document into the XML Parser. <script type="text/javascript"> var xmlDoc=new ActiveXObject("Microsoft.XMLDOM") xmlDoc.async="false" xmlDoc.load("note.xml") *** *** *** </script> Ques: 11 How XML support UNICODE characters ? Ans: Generally XML doesn't support UNICODE character. But this makes possible when we using some techniques in XML.These techniques are given below: <?xml version="1.0" encoding="windows-1252"?> <?xml version="1.0" encoding="ISO-8859-1"?> <?xml version="1.0" encoding="UTF-8"?> <?xml version="1.0" encoding="UTF-16"?>.

Ques: 12 How to create an XML Document? Explain it with example. Ans: We you again in XML we can create our own tags.I have given you a XML example given below. Example: <?xml version="1.0" encoding="ISO-8859-1"?> <note> <to>abhi</to> <from>vivek</from> <heading>Welcome</heading> <body>Hi! R4R Welcomes you.At this Place you can check or improve your intelligency. </body> </note> When we see this code we can easily understand that vivek send a message to abhi.Because we uses to and from self defined tags. Ques: 13 How XML support TREE Structure? Ans: In XML document we called root element to the parent node and create other child tags with in the root.So,It creates a structure like tree.In this tree starts at the root and branches made at the lowest level of the tree.I have given you a example which shows a tree structure.Syntax:<root> <child> <subchild>.....</subchild> </child></root>Example:<bookstore><book category=\"JAVA\"> <title lang=\"en\">The Complete Reference</title> <author>Herbert Schildt</author> <year>2005</year> <price>30.91</price> </book><book category=\"C++\"> <title lang=\"en\">Programming in ANSI C+ +</title> <author>E Balaguruswamy</author> <year>2007</year> <price>38.99</price> </book><book category=\"C\"> <title lang=\"en\">Exploring C</title> <author>Yashwant kanetkar</author> <year>2006</year> <price>42.95</price> </book></bookstore> Above, I have started with bookstore category. It is called root node.Than after create a child node like:book.Than creates the attributes like:title,author,year and price attributes and assign values to them.This is look like a tree shape structure. Ques: 14 Write some basic rules of XML? Ans: I think their is no problem comes when we using XML rules.Because XML has no pre-defined tags.so, it can easy implement and made logical arranged data.Some basic rules of XML given below.Keep in mind when you creating any XML document. Rule1: ALL tags that you open should have been closed.Like:<Welcome>......</Welcome> Rule2:XML Tags are Case-Sensitive.So,if you create tag like:<Welcome> than you can't closed this tag with </welcome>.You should write </Welcome>. Rule3:XML element should be properly nested. Example:<R4R><Welcome>.......</R4R></Welcome> is false. <R4R><Welcome>.......</Welcome></R4R> Rule4:Document should have a root node. <root> <child> <subchild>.....</subchild> </child> </root> Rule5:We should the attribute values. <note date="03/02/2008"> <to>abhi</to>

<from>vivek</from> </note> Ques: 15 How to define XML Element? Ans: Everything inside the open and closed tag is called as XML Element.It may be contain other element and text or may be a combination of both. I have given you example which help you to understanding element in XML. <bookstore> <book category="JAVA"> <title lang="en">The Complete Reference </title> <author>Herbert Schildt</author> <year>2005</year> <price>30.91</price> </book> <book category="C++"> <title lang="en">Programming in ANSI C++</title> <author>E Balaguruswamy</author> <year>2007</year> <price>38.99</price> </book> <book category="C"> <title lang=\"en\">Exploring C</title> <author>Yashwant kanetkar</author> <year>2006</year> <price>42.95</price> </book> </bookstore> Above,bookstore and book both are element content where as title,author,year and price are text content.book also called as attribute and JAVA,C++ and C is the value of book attribute. Ques: 16 How you define attributes in XML? Ans: We define attribute in XML as same as HTML.But keep one thing in mind In XML every attribute should have a value,We can't make attribute without value in XML.Where as in case of HTML we can create attribute without value. Example: <student active="true"> <name>Abhi</name> <grade>A</grade> </student> In above example 'student' is a element,'active' is a attribute and 'true' is a attribute value. <student active> <name>Abhi</name> <score>75</score> </student> This is wrong in case of XML because in this we declare attribute 'active' without any value.But it will run in case of HTML. Ques: 17 How you define XML Entity? Ans: Using Entity we can represent the information in symbolic form. Syntax: When we write entity in the XML.We start with ampersand(&),after that write name than after write semicolon(;) &entity_name; Here,I am writing a syntax to create XML entities.

<!ENTITY entityname "write information according to entity."> Example: <!ENTITY welcomenote "Hello,I am Vivek.R4R welcome you! and enjoy after getting membership of R4R."> Further,I given you a example how to use a XML entity. Example: <!ENTITY welcomenote "Hello,I am Vivek.R4R welcome you! and enjoy after getting membership of R4R."> <email> <to>client</to> <body>&welcomenote;</body> </email> Ques: 18 How to write comment in XML? Ans: We use comment in XML to temporary write the note or want some code to edit on XML document.Some time writing a comment is very necessary for program. XML does not provide any special method for writing a comment it is same as HTML.Below I have given a code how to write comment on XML. Example: <?xml version="1.0" encoding="ISO-8859-15"?> <!-- Student that marks on half yearly exam --> <class_student_list> <student> <name>Hariom</name> <score>70%</score> </student> <student> <name>Abhi</name> <score>75%</score> </student> </class_student_list> Below I have given you a example in this i have remove some data about student temporarily. Example: <?xml version="1.0" encoding="ISO-8859-15"?> <!-- Student that marks on half yearly exam --> <class_student_list> <student> <name>Hariom</name> <!-- <score>70%</score> --> </student> <student> <name>Abhi</name> <!-- <score>75%</score> --> </student> </class_student_list> In this I have remove score temporarily. Ques: 19 How you define DTD in XML? Ans: DTD is stands for Document Type Definition.This is the oldest schema for XML.It is present every where in the XML 1.0.I have you reasons those make DTD limited. 1.It does not new features of XML.Like:namespaces.2.It lacks

expressiveness.We can\'t captured the formal aspects of XML doc.3.DTD uses a custom non-XML syntax,inherited from SGML. Example: <!ELEMENT people_list (person*)> <!ELEMENT person (name, age?, sex?, phoneno?)> <!ELEMENT name (#PCDATA)> <!ELEMENT age (#PCDATA)> <!ELEMENT sex (#PCDATA)> <!ELEMENT phoneno (#PCDATA)> Ques: 20 What is the XML prolog? Ans: IN XML their is no mandatory to use prolog it is optional.But if we want to use than it comes before the root element in XML.prolog has two parts these are, 1.XML Declaration 2.Document Type Declaration We can use both parts at same time,alone or not mandatory to use.

XML Interview Questions And Answers

Page 1
Ques: 1 Define XML namespace? Ans: XML Namespaces provide a method to avoid element name conflicts.XML namespace is a collection of element type and attribute names.A reasonable argument can be made that XML namespaces dont actually exist as physical or conceptual entities. Ques: 2 Does XML replace HTML? Ans: 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. Ques: 3 Define XMLHttpRequest Object? Ans: Using XMLHttpRequest Object: 1. Updated a web page without reloading. 2. Requesting for data from a server after the page has loaded. 3. Receive data from a server after the page has loaded. 4. Send data to a server in the background. XMLHttpRequest Object creating like: xmlhttp=new XMLHttpRequest(); Ques: 4 What are basic problems to using Attributes? Ans: Some of the problems with using attributes are: 1. Attributes cannot contain multiple values 2. Attributes cannot contain tree structures 3. Attributes are not easily expandable Attributes are difficult to read and maintain. Use elements for data. Use attributes for information that is not relevant to the data.

Ques: 5 define XML Elements, Attributes with example? Ans: There are no rules about when to use attributes or when to use elements. For Example: 1. <person sex="female"> <firstname>Anna</firstname> <lastname>Smith</lastname> </person> 2. <person> <sex>female</sex> <firstname>Anna</firstname> <lastname>Smith</lastname> </person> In the first example sex is an attribute. In the last, sex is an element. Both examples provide the same information. Ques: 6 Define Syntax rules in XML in brief? Ans: 1. All XML Elements Must Have a Closing Tag 2. XML Tags are Case Sensitive 3. XML Elements Must be Properly Nested 4. XML Documents Must Have a Root Element 5. XML Attribute Values Must be Quoted 6. Entity References: &lt; < less than &gt; > greater than &amp; & ampersand &apos; ' apostrophe &quot; " 7. Comments in XML 8. White-space is Preserved in XML Ques: 7 What software is needed to process XML Namespaces? Ans: There is no need for any special XML namespace software. Ques: 8 What is an XML namespace name? Ans: XML namespace name is a URI that uniquely identifies the namespace. URIs is used because they are widely understood and well documented. Because people may only allocate URIs under their control, it is easy to ensure that no two XML namespaces are identified by the same URI. Ques: 9 Define essential components of security does the XML Signatures provide? Ans: Three Components are: 1. Authentication 2. Message integrity and 3. Non-repudiation In addition to signature information, an XML Signature can also contain information describing the key used to sign the content. Ques: 10 Define some terms when naming the element in XML? Ans: 1. Element names can contain any character including letters and numbers. 2. Element names must not contain spaces 3. Element names must not begin with a number or punctuation character (for example a comma or semi-colon etc).

4. Element names must not start with the letters xml (whether lowercase, uppercase, or mixed case) Ques: 11 In XML elements have nested properly.Define? Ans: Placed elements inside other elements but needed to ensure each element's closing tag doesn't overlap with any other tags. Wrong declaration is: <R4R> <name>XML</R4R> </name> Right declaration is: <R4R> <name>XML</name> </R4R> Ques: 12 'Tags Are Case Sensitive' how, define ? Ans: All tags must be written using the correct case. XML sees <tutorial> as a different tag to <R4R> The wrong declaration is : <r4R>XML</R4r> Right Declaration is: <R4R>XML</R4R> <r4r>XML</r4r> <r4R>XML</r4R> Ques: 13 Define Child Elements and Content in any XML Program? Ans: 1. Elements that are contained within the root element,represented by an opening and closing tag,Data and other elements reside between them. 2. XML allows you to use empty elements. An empty element is one without a closing tag. Like HTML you must close empty elements with a forward slash before the > symbol. For example, <br />. 3. Elements can also contain one or more attributes. An attribute is a name/value pair, that you place within an opening tag, which allows you to provide extra information about an element. Ques: 14 Define <?xml-stylesheet type="text/css" href="myStyles.css"?> in brief? Ans: It means processing instructions, begin with <? and end with ?>. Processing instructions are instructions for the XML processor. Processing instructions are not built into the XML recommendation. Ques: 15 Define <!-- Here is a comment --> brief? Ans: XML comments begin with <!-- and end with -->. Similar to HTML comments, XML comments allow you to write stuff within your document without it being parsed by the processor. Ques: 16 Define brief \"<!doctype document system \"R4R.dtd\">\" ? Ans: This syntax means Document Type Definition (DTD),defines the rules of your

XML document,XML itself has rules,the rules defined in a DTD are specific to your own needs.The DTD is used when you validate your XML document.DTDs can be internal (i.e. specified within the document) or external (i.e. specified in an external file). Ques: 17 Define "<?xml version="1.0" encoding="UTF-8" standalone="no"?>" in brief? Ans: 1. ?xml version="1.0": XML declaration indicates that the document is written in XML and specifies which version of XML. 2. encoding="UTF-8": Language encoding for the document (optional) and if the application refers to external entities (optional). 3. standalone="no": This is not a standalone document as it relies on an external resource (i.e. the DTD). Ques: 18 Give examples of XML Editors? Ans: 1. XML Notepad 2. XML Cooktop 3. XML Pro 4. XML Spy 5. eNotepad Ques: 19 Describe benefits of an XML Editor? Ans: 1. When coding XML, it will help prevent you from making errors. 2. XML editor should also provide validation a way for you to validate that the documents you create are well formed. 3. XML editors are similar to HTML editors in that they provide syntax highlighting which helps with readability when you're coding. 4. Automatically insert a closing tag once you're added an opening tag like HTML editor. Ques: 20 Define steps necessary to parse XML documents? Ans: 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.

XML Interview Questions And Answers

Page 1
Tot Show al Post Your Answers Pos Answers ts Show Answers Show Answers Post Your Answers Post Your Answers

Questions

Last Post

XML stands for? a. eXtra Markup Language b. eXplore Markup Language c. eXpensive Markup Language d. eXtensible Markup Language Main purpose to design XML is? a. save and transport data b. how to reuse data c. to made connection b/w data

sanjaysahu 05.02.09 Vivek

d. how to use data XML is Case-Sensitive Language or not? Which one is correct? a. <NAME>Write name here</NAME> b. <name>Write name here</name>

Show Answers Show Answers

Post Your Answers Post Your Answers

sanjaysahu 05.02.09 Vivek

Potrebbero piacerti anche