A Friendly Approach to XML - What You Can Do with XML
(Page 3 of 4 )
Creating Your Own Markup
XML's brother, HTML (hypertextual markup language), as you probably know, is a language for creating web pages on the Internet. It has a set of predefined tags that coders use to display data and media on the Internet. These predefined tags, such as the <p> or paragraph tag, which allows you to create paragraphs, and the <b> tag, which creates bold text, can sometimes be restrictive, in that you cannot customize any tags to allow for any new type of data. I am reaching here a little bit, but as I get further into this section, it will begin to make more sense.
XML steps in to solve this issue. Say that I have a table in HTML that contains some song titles. The rows and data inside the table would look something like this:
<tr>
<td> Alive</td>
<td> Sexyback</td>
<td> She Thinks My Tractor Is Sexy </td>
<tr>
In HTML this table is just a list of song titles. That is, I can't easily define the data in each record without a bunch of hassle. XML comes in and saves the day by allowing us to give data to our data, or in simpler terms, to give context to the data in the table.
There exists no <genre> tag in HTML (there are of course ID3 tags for audio files, but that is another tutorial). With XML, however, we can create one. We could create any tag we wanted. We could have an <artist> tag, a <price> tag, and a <rating> tag, allowing us to give additional information about the data. So now in addition to song title, we have artist, price, genre, and rating, all of which make the field sortable and give a clearer vision of what our data is all about. After all, what good is data without a frame of reference?
If this seems a little fuzzy to you, don't worry too much about it. We will cover it in greater detail in our next article.
Next: Keeping Your Data and Context Separated >>
More XML Tutorials Articles
More By James Payne