Example of XML Document


Datafile Software

Example of XML Document


The example below is taken from Microsoft’s Introduction to XML, from their web-site, and is a weather report.

† BASDA — Business Accounting Software Developers Association, a UK initiative that now includes most of the world’s major accounting and commercial software companies, including Datafile Software

What is immediately apparent is how easy it is to read this and understand what it means. It might as well say "Weather report dated March 25th, 2003 at 8.00 a.m. from Seattle, WA, in the West Coast region of the USA. Skies will be partly cloudy, temperature 46ºC, wind direction from the southwest of force 6. The humidity index is 51, with a humidity of 87%, visibility 10 miles, and a U/V index of 1”.

What should also be apparent to someone who has some familiarity with HTML is how similar to an HTML page this XML document looks. Content that is clearly data (such as the date and time) are "tagged†” front and back just like the content in an HTML page.

HTML, however, has a limited number of pre-defined tags — such as "<h1>” "<h2>” and so on to define heading levels — and their meaning and uses (or semantics) are fully defined by HTML standards. In XML, neither the set of allowable tags nor their semantics are defined by the XML standard.

In fact XML is really a meta-language for describing a markup language, telling you how to define tags and the structural relationships between them that — taken as a whole — define the complete document. Provided you stick to the few rules, how you use this language to create an XML document is up to you.

The combination of an opening and closing tag together with everything in between is known in XML as an "element”. The top-level element — in the example above, weather-report — is known as the "root” element. Any element below another element is known as a "child” element. In the example above, date, time, area and measurements are all child elements of weather-report; wind is a child element of measurements, and direction is a child element of wind.

Within the opening tag may be additional information, known as attributes, that may modify how the data between the tags is to be treated.

† "Tags” are enclosed within angle brackets "<” and ">”, and the closing tag starts "</”. In the example above "<date>”and "</date>” are the start and end tags for the date given: "2003-03-25”.
Custom Fields

Article ID: 1860
Created On: Tue, Jul 10, 2012 at 12:23 PM
Last Updated On: Thu, Jun 22, 2023 at 4:43 PM

Online URL: https://kb.datafile.co.uk/article/example-of-xml-document-1860.html