XML Interview Questions

XML Tutorial for Beginners : Learn XML Online

The XML Tutorial encompasses both the basic and complex concepts of XML, making it a great resource for both novices and specialists to study XML online. XML stands for Extensible Markup Language. The World Wide Web Consortium (W3C) developed this brand-new markup language largely to remedy HTML’s drawbacks. Most notably HTML, the W3C is in charge of developing and maintaining the bulk of Web standards.

An very well-liked markup language is HTML. According to some estimations, there are 800 million HTML-based Web pages. Many applications support HTML, including editors, email clients, databases, contact management systems, and browsers.

Initially, scientific documents were published on the Web. Similar to print and television, it is now a fully evolved form of media. Since it supports services like online shops, electronic banking, trade, and forums—which are more significant—the Web is an interactive medium.

XML Tutorial Quick Guide

What is XML?

The most significant development on the Internet in recent years is Extensible Markup Language (XML). XML is a potent, extremely dynamic subject that cuts across dozens of domains, from the very basic to the most complicated.


HTML has evolved over time to accommodate this remarkable popularity. There have been several new tags added. In the first version of HTML, there were 12 tags; in HTML 4.0, the most recent version, there are approximately 100 tags (excluding browser-specific elements).

HTML, however, is not without its drawbacks. It has developed into a sophisticated tongue. It is definitely not a little language with approximately 100 tags. There are virtually infinite combinations of tags, and the outcome of a given combination of tags may vary from one browser to the next.

Finally, despite the fact that HTML already has all of these tags, more are still needed. Applications for electronic commerce require tags for data on goods, costs, names, addresses, and other information. For streaming to control the flow of audio and graphics, tags are required. Search engines demand more precise description and keyword tags. To sign a secure document, tags are necessary. There are practically countless applications that call for new HTML tags.

Tags, attributes, comments, and directions for processing the text make up markup in a broader sense. The tag identifies the start and end of a piece of material. In other words, there must be a start tag and an end tag that match the content.

XML Tag

An element is identified with a tag, which may additionally have additional information identifying its content. The name and any further information are enclosed in a start tag using the characters and >. An end tag, like a start tag, is made up of the tag name (which must match the tag name in the start tag). and

< / and >. For example, the following XML entity
<CYL> 6 </CYL>

CYL element with content 6. It is possible to have empty tags, i.e. tags with no content,

<CYL></CYL>

In this case the start and end tags can be combined into one tag as follows,

CYL/>.

Attributes provide additional information about the content. For example, the dim tag below has a size attribute which has a value of 2.

<dim size="2">

Attributes are specified via name-value pairs.

XML Validation 

The principles listed above are merely suggestions for syntax that will guarantee the consistency of an XML document. But more often than not, we also want the markup in our documents to have application-specific structure. For example, while utilizing geographic data, we may require city names, x and y coordinates, place tags, etc. Document Type Definitions (DTD) or schema from various sources offer the tags for these items. With a DTD, we may specify the attributes that must or may be present in the tag, as well as the name of a legal element, the restriction of an element’s content to character data, and the need that some other elements be empty.

While valid XML also adheres to a specified DTD in addition to being well-formed, well-formed XML complies with the XML syntax standards outlined in the previous section. The DTD may be referenced or it may be present in the document itself.

<!DOCTYPE dataset SYSTEM "../DataSetByRecord.dtd">

Here, a document type declaration is used to specify the DTD to be used. The root element name that will be subject to the DTD application throughout the verification process is provided by the dataset.

There may be times when we need to employ more than one DTD. This is made possible by the use of name spaces. To put it another way, each DTD has a name that is added to the names of the appropriate tags and attributes. For instance, the URLs and names of the associated DTDs for the three name spaces r, c, and bioc are included in the object element below.

<object xmlns:r="http://www.r-project.org"
xmlns:c="http://www.c.org"
xmlns:bioc="http://www.bioconductor.org"
type="R-pop-environment" hidden="true">
We specify which name space a tag uses within the object element as follows:
<r:code>
x <- rep(23, 2)
</r:code>
<c:code>
x+
</c:code>

XML Tutorial for Beginners

Tutorial : How to Transform XML with XSLT?

Tutorial : What is XML DTD? How to declare in XML file?

Basic XML Document

Step 1: please try to write small XML syntax and type the code below into CodeRunner as shown below,

<?xml version="1.0"?>
<HelloWorld>
<Message>This is my first XML document!</Message>
</HelloWorld>

Step 2: When yo u finish, click the Check Syntax button,

Step 3: f yo u typed everything correctly, yo u will see No errors found..

Congratulations! Yo u just created your first XML document!

Differences Between XML and HTML

Since HTML is a markup language like XML, they have many similarities, but there are a few key differences between HTML and XML too.

Here are some fundamental differences you should be aware of

  • With HTML, small errors in syntax are often ignored.
  • HTML has only pre-defined tags, whereas XML tags are created by the author.
  • Documents can be structured logically in XML (the author chooses the appropriate structure), while HTML has a pre-defined “head” and “body” type structure.

XML isn’t necessarily useful by itself. The flexibility to transform it into different forms, like HTML, is one of its major strengths.XML has different rules than HTML because it was created for a different purpose. Most of the differences in XML syntax between HTML and HTML aid in speeding up and making XML document parsing simpler. Errors are not allowed in XML! It should be clear to you how these variations work. If they don’t, kindly have another look at the HTML course.

Some of the areas where XML will be useful in the near-term include:

  • large Web site maintenance. XML would work behind the scene to simplify the creation of HTML documents
  • exchange of information between organizations
  • offloading and reloading of databases
  • syndicated content, where content is being made available to different Web sites
  • electronic commerce applications where different organizations collaborate to serve a customer
  • scientific applications with new markup languages for mathematical and chemical formulas
  • electronic books with new markup languages to express rights and ownership
  • handheld devices and smart phones with new markup languages optimized for these “alternative” devices

XML Applications

Although I have told my other post in passing that XML is not just for Web site publishing, all the examples I have given so far are more or less related to Web publishing. In this topic, I will present some of the most popular XML applications

Applications of XML are classified as being of one of the following two types:

  • Document applications manipulate information that is primarily intended for human consumption.
  • Data applications manipulate information that is primarily intended for software consumption.

The difference between the two types of application is a qualitative one. It is the same XML standard, it is implemented by using the same tools, but it serves different goals. This is important because it means you can reuse tools and experience across a large set of applications.

Document Applications

The first application of XML would be document publishing. The main advantage of XML in this arena is that XML concentrates on the structure of the document, and this makes it independent of the delivery medium

Therefore, it is possible to edit and maintain documents in XML and automatically publish them on different media. The operative word here is automatically.

Due to the availability of many publications both online and in print, the capacity to target different media is becoming increasingly crucial. Additionally, the Web is evolving quite quickly. Finally, some websites, like Netscape or Internet Explorer, are tailored for particular viewers. This frequently results in the creation of two or more variations of the same website: one that is optimized for all users and another that is more user-specific. This is quite expensive to perform manually.

Data Applications

Giving document management access to the software tools that had previously been used to manage data, such as databases, was one of the initial purposes of SGML.The loop has been completely closed by XML since it gives data a publishing-style dissemination. As a result, the idea of “the application as the document” emerges, according to which there is ultimately no distinction between papers and applications.

List of Products in XML

<?xml version=”1.0”?>
<products>
<product id=”p1”>
<name>XML Editor</name>
<price>499.00</price>
</product>
<product id=”p2”>
<name>DTD Editor</name>
<price>199.00</price>
</product>
<product id=”p3”>
<name>XML Book</name>
<price>19.99</price>
</product>
<product id=”p4”>
<name>XML Training</name>
<price>699.00</price>
</product>
</products>

In this context, XML is used to exchange information between organizations. The XML Web is a large database on which applications can tap.This can be viewed as an extension for extranets. The idea behind an extranet is that one organization publishes some of its data on the Web for its partners.

XML Style Sheets

Two style sheet languages, XSL (XML Stylesheet Language) and CSS (Cascading Style Sheet), are compatible with XML. The associated standards that are most frequently discussed are style sheets. They define how XML documents should be displayed in an editor, on paper, or both. Although CSS is more widely used, XSL is more powerful.

XML DOM and XML SAX

XML documents can be accessed via the DOM (Document Object Model) and SAX (Simple API for XML) APIs. They work similarly to translators in that they let applications read XML documents without having to care about the syntax. They work best together: SAX is great for application-to-application interchange, whereas DOM is best for forms and editors.

XML Browser

The first application that comes to mind is an XML browser because it is so similar to the well-known HTML browser. XML documents are viewed and printed using an XML browser. At the time of writing, there aren’t many excellent XML browsers available.

Since version 4.0, Microsoft Internet Explorer has supported XML. The XML support has been significantly improved in Internet Explorer 5.0. Unfortunately, the support is incomplete and is based on early versions of the style sheet standards. However, Internet Explorer 5.0 is now the closest approach to a widely used XML browser.

Mozilla, Netscape Communicator’s open-source variant, is the only application that presently supports XML in Netscape Communicator. XML is well supported by Mozilla. Mozilla is currently a work-in-progress, thus it is not yet reliable enough for use in everyday situations.

XML Editors

A person must have written the document before it may be read. Unexpectedly, there are many different XML editors available. But some of these editors—like Adobe Framemaker—are streamlined versions of SGML editors, while others—like XML Pro—are entirely original.

The market is seeing the entry of new editors, led by products like SoftQuad’s XMetaL. These editors combine the usability of an XML product with the capability of SGML editors.

XML Parsers

If you are writing your own XML applications, you probably don’t want to fool around with the XML syntax. Parsers shield programmers from the XML syntax.

There are many XML parsers available on the Internet, such as IBM’s XML for Java. Also an increasing number of applications include an XML parser, such as Oracle 8i.

XSL Processor

In many cases, you want to use XML “behind the scene.” Although you wish to utilize XML internally, you don’t want to have your users switch to an XML-compliant browser. You’ll use XSL in each of these scenarios. With the help of XSL, you can create traditional HTML that is compatible with modern browsers as well as older ones while still retaining the benefits of XML inside.

XML Tutorial for beginners explain what XML, and it gives a brief understanding of messaging and important XML language concepts are explained above post. I will be adding more posts in XML tutorial, so please bookmark the post for future reference too.