XML Tutorial

XML HOME XML Introduction XML How to use XML Tree XML Syntax XML Elements XML Attributes XML Namespaces XML Display XML XSLT XML XPath XML XLink XML Validator XML DTD XML Schema XML Server XML HttpRequest XML Parser XML Examples XML Quiz XML Certificate


AJAX Intro AJAX XMLHttp AJAX Request AJAX Response AJAX XML File AJAX PHP AJAX ASP AJAX Database AJAX Applications AJAX Examples


DOM Intro DOM Nodes DOM Accessing DOM Node Info DOM Node List DOM Traversing DOM Navigating DOM Get Values DOM Change Nodes DOM Remove Nodes DOM Replace Nodes DOM Create Nodes DOM Add Nodes DOM Clone Nodes DOM Examples

XSLT Tutorial

XSLT Intro XSL Languages XSLT Transform XSLT <template> XSLT <value-of> XSLT <for-each> XSLT <sort> XSLT <if> XSLT <choose> XSLT Apply XSLT on the Client XSLT on the Server XSLT Edit XML XSLT Examples

XPath Tutorial

XPath Intro XPath Nodes XPath Syntax XPath Axes XPath Operators XPath Examples

XQuery Tutorial

XQuery Intro XQuery Example XQuery FLWOR XQuery HTML XQuery Terms XQuery Syntax XQuery Add XQuery Select XQuery Functions


DTD Intro DTD Building Blocks DTD Elements DTD Attributes DTD Elements vs Attr DTD Entities DTD Examples

XSD Schema

XSD Intro XSD How To XSD <schema> XSD Elements XSD Attributes XSD Restrictions

XSD Complex

XSD Elements XSD Empty XSD Elements Only XSD Text Only XSD Mixed XSD Indicators XSD <any> XSD <anyAttribute> XSD Substitution XSD Example

XSD Data

XSD String XSD Date XSD Numeric XSD Misc XSD Reference

Web Services



DOM Node Types DOM Node DOM NodeList DOM NamedNodeMap DOM Document DOM Element DOM Attribute DOM Text DOM CDATA DOM Comment DOM XMLHttpRequest DOM Parser XSLT Elements XSLT/XPath Functions

How Can XML be Used?

XML is used in many aspects of web development.

XML is often used to separate data from presentation.

XML Separates Data from Presentation

XML does not carry any information about how to be displayed.

The same XML data can be used in many different presentation scenarios.

Because of this, with XML, there is a full separation between data and presentation.

XML is Often a Complement to HTML

In many HTML applications, XML is used to store or transport data, while HTML is used to format and display the same data.

XML Separates Data from HTML

When displaying data in HTML, you should not have to edit the HTML file when the data changes.

With XML, the data can be stored in separate XML files.

With a few lines of JavaScript code, you can read an XML file and update the data content of any HTML page.


<?xml version="1.0" encoding="UTF-8"?>

  <book category="cooking">
    <title lang="en">Everyday Italian</title>
    <author>Giada De Laurentiis</author>

  <book category="children">
    <title lang="en">Harry Potter</title>
    <author>J K. Rowling</author>

  <book category="web">
    <title lang="en">XQuery Kick Start</title>
    <author>James McGovern</author>
    <author>Per Bothner</author>
    <author>Kurt Cagle</author>
    <author>James Linn</author>
    <author>Vaidyanathan Nagarajan</author>

  <book category="web" cover="paperback">
    <title lang="en">Learning XML</title>
    <author>Erik T. Ray</author>


You will learn a lot more about using XML and JavaScript in the DOM section of this tutorial.

Transaction Data

Thousands of XML formats exists, in many different industries, to describe day-to-day data transactions:

  • Stocks and Shares
  • Financial transactions
  • Medical data
  • Mathematical data
  • Scientific measurements
  • News information
  • Weather services

Example: XML News

XMLNews is a specification for exchanging news and other information.

Using a standard makes it easier for both news producers and news consumers to produce, receive, and archive any kind of news information across different hardware, software, and programming languages.

An example XMLNews document:

<?xml version="1.0" encoding="UTF-8"?>
    <title>Colombia Earthquake</title>
      <hl1>143 Dead in Colombia Earthquake</hl1>
      <bytag>By Jared Kotler, Associated Press Writer</bytag>
      <location>Bogota, Colombia</location>
      <date>Monday January 25 1999 7:28 ET</date>

Example: XML Weather Service

An XML national weather service from NOAA (National Oceanic and Atmospheric Administration):

<?xml version="1.0" encoding="UTF-8"?>

<credit>NOAA's National Weather Service</credit>

  <title>NOAA's National Weather Service</title>

<location>New York/John F. Kennedy Intl Airport, NY</location>
<observation_time_rfc822>Mon, 11 Feb 2008 06:51:00 -0500 EST

<weather>A Few Clouds</weather>