XML
XML
XML Basics
SCORM
SCORM
SCORM Overview
Content Aggregation Model
Content Aggregation Model
CAM Overview
XML Namespaces
Runtime Environment
Runtime Environment
RTE Overview
CMI Data Model
Sequencing & Navigation
Sequencing & Navigation
S&N Overview
LOM
LOM
LOM Overview
About
About
Contact Us
Contact Us
Skip Navigation LinksHome > XML Basics

XML Basics

What is XML?

The Extensible Markup Language better known as XML is a flexible framework for creating customized markup languages. So now you ask; what's a markup language? The answer isn't as painful as you may think. Essentially a markup language is a symbolic way of representing text in a structured and formatted manor. One of the best known is HTML.

XML Schema

An XML Schema is a controlling document in which, rules and constraints may be defined that govern how a specific type of XML document should be created. These constraints are much like the syntactic rules we learned back in school for creating sentences. A schema defines when and where various markup may be used. A schema is used to verify that an XML document is valid. That is that the document is written in such a way that the metaphoric sentences make sense.

XML Syntax

There are two levels of correctness which an XML document must meet. XML documents must be both well-formed and valid.

  • A well-formed document meets the basic syntactic requirements required of an XML based markup language.
  • A valid document is well-formed and meets the syntactic constraints defined in the documents associated schema.

The basic xml document syntax is comprised of several high level pieces that which are at the foundation of an XML documents syntax. These primary elements are:

  • Elements
  • Attributes
  • Namespaces

If you’re interested in learning more about XML syntax we recommend the XML.com, Technical Introduction to XML.

XML Elements

The XML Element is the primary component which comprises a documents structure. An Element is a container for information and other Elements.

XmlElementExample.xml
<?
xml
version="1.0" {name1}="{val1}" ?>
<car>
    
<vin />
    
<engine>
        
<emmissionsSystem>
            
<massAirFlowSensor>4572661466644666</massAirFlowSensor>
            
<oxygenSensor>777886112134312533</oxygenSensor>
        
</emmissionsSystem>
    
</engine>
</car>

In this XML example we start with our highest level element, called the root or document level element, the "car". From there you see that we continue breaking down and categorizing information, using additional elements. This document describes a car’s engine emission system parts, maybe providing part numbers or other relevant information. An element begins with a start tag "<car>" and must always be followed by a closing tag "<car>". Notice that a closing tag contains the "/" character. Some elements which do not contain other elements between the start and end tag may also self close as we see with "<vin />".

XML Attributes

The XML Attribute provides information about data contained within an XML Element. Attribute data is a generally not part of the Element data itself but rather serves to provide extended information about the Element data.

XmlAttributeExample.xml
<?
xml
version="1.0" {name1}="{val1}" ?>
<car modelYear="1992">
    
<vin />
    
<engine>
        
<emmissionsSystem>
            
<massAirFlowSensor>4572661466644666</massAirFlowSensor>
            
<oxygenSensor>777886112134312533</oxygenSensor>
        
</emmissionsSystem>
    
</engine>
</car>

In this XML example we see that the <car> element now looks a little different. We have added an attribute to this element which provides the model year of the vehicle described by xml example.

XML Namespaces

An XML namespace is a little difficult to understand for most xml newbie’s without an explanation of the problem they are meant to resolve. Much like a telephone area code, which enables the use of the same seven digit number in multiple areas, a namespace helps to ensure that elements from multiple schema definitions may be used within the same xml document without the potential problem of naming collisions. A naming collision is a situation where two different xml based markups use the same element name to represent different data. A namespace qualifies an element providing an indication of the specific schema that it belongs to.