Assume that you're working with a file that looks like this:
Learn XML in A Weekend, ScienceZen, 1000000001A
This File describes information about an a book using three fields: the title, author, and ISBN (International
Serial Book Number - a number that uniquely identifies a book). While it's clear to you and me that Learn
XML in A Weekend represents the title of a book, a computer would have a tough time figuring out that
> There are three fields in the file (separated by commas).
> Each field represents an individual piece of data.
XML enables you to add structure to the data. Here's the same file marked up with XML:
<books>
<book>
<title>Learn XML In A Weekend</title>
<author>ScienceZen</author>
<isbn>1000000001A</isbn>
</book>
</books>
It's now apparent, both to us and to software that's capable of interpreting XML, that the file contains infor
mation about a collection of books (there's only one book in this collection) broken into three fields: title,
author, and ISBN. For software to be able to interpret the XML, the sample follows certain rules:
>Text inside the angle brackets (< and >) represents a markup element
>Text outside of the angle brackets is data
>The beginning of a unit of data has a start tag prefix.
>The end of a unit of data is marked with an end tag. This is almost identical to a start tag, except that it
ends with a slas (/).
For example, <title> is a start tag, Learn XML in A Weekend represents a unit of data, and </title> is an
end tag. XML defines only the syntax---the rules---and leaves it to you to decide how you structure it and
what data you store in it.
XML documents reside in files that you can create with an editor like Windows Notepad, making XML very
accessible. Specialized editors are available to help you manage XML documens and ensure that you
follow the rules of the XML specification. I'll cover two of such editors later in this topic.
Note----> Windows Notepad is a simple text editor that comes with Windows. You can start Notepad by
clicking Start, Run, and then typing notepad.
It is important to understand that XML is an enabling technology, which is analogous to any written or
spoken language. A language doesn't communicate for us. We're able to communicate because we use
language.
Just as you play a role in reading the words on this page (the words are meaningless, unless someone
reads them), XML becomes useful only in the context of a system that's able to interpret it. Unlike written
and spoken languages, you're not likely to directly read or write XML. People rarely read XML documents
---- in most cases, software creates an XML file and then other software uses it without anyone actually
viewing the XML document itself. However, you still need to understand what XML is and how to use it to
your advantage.
There are three important characteristics of XML that make it useful in a variety of systems and solutions:
> XML is extensible.
> XML separates data from presentation.
> XML is a widely accepted public standard.
XML is Extensible
Think of XML like this: one syntax, many languages.
XML describes the basic syntax----the basic format----and rules that XML documents must follow.
Unlike markup languages like HTML, which has a predefined set of tags (items with the angle brackets, as
in the previous sample), XML doesn't put any limitations on which tags you can use or create. For example
there isn't any reason you couldn't rename the <book> tag to <manuscript> or <record>.
XML essentially allows you to create your own language, or vocabulary, that suits your application. The
XML standard (described shortly) describes how to create tags and structure an XML document, creating
a framework. As long as you stay within the framework, you're free to define tags that suit your data or
application.
Read our next article on XML Separates Data from Presentation
0 comments:
Post a Comment