11.22.07

Basic XML Syntax

Posted in XML Scripts at 11:49 am by admin

XML is a language that was developed for a very specific purpose. The purpose of XML is to provide a compliment to HTML and therefore allow you to store your data outside of the actual HTML document. As you get more advanced in your programming, you will realize that there are times when this can be a very important thing to have. For now however, it is sufficient just to understand that XML is primarily used to separate data from the HTML code.

In order to understand the syntax for XML (which is actually perhaps the simplest set of syntax rules around; certainly many people that have been forced to learn XML on a very quick crash course would agree that they are the simplest), it is best to do so through the use of a note. Since we have been big on the Hello World examples in other coding instructions, we will use the same here.

The following script:

<?xml?>
<note>
<to>World</to>
<from>Me</from>
<heading>Hello World</heading>
<body>Hello World!</body>
</note>

Accomplishes something similar to the typical ‘Hello World’ example.

The XML tag is a tag that is used to let whatever is reading the software know that the following lines of code are xml code. The <note> and </note> tags define that the upcoming document is a note. The <to> and </to> tags define person that this note is being addressed to, while the <from> and </from> tags do the opposite; they let the viewer know who the note is being sent from.

The <heading>, </heading>, <body> and </body> tags define the headings and the body of the actual note. If you were writing this as an e-mail instead of as a note, then the heading would be the subject line and the body would be the actual e-mail; just to give you a suitable frame of comparison.

As you review this script, chances are that it is starting to occur to you why XML is thought of as one of the simplest languages around to learn. Most of the XML language itself is quite self-descriptive and when something is self-descriptive, that can easily lend itself towards being easy to learn. As you continue to expand your knowledge of XML and learn the language, chances are you are going to see this idea of simplicity in self-description echoed again and again. The sooner you understand that this idea applies to all of the XML syntax, the quicker your XML education will go.

Scriptycan is a great software repository featuring both free and commercial XML Scripts and applications for developers and programmers.