-
Step 1
XML open tag< ?xml version="1.0">
* Remove the white space between "< ?".
This is the opening tag of an XML document. This eHow article will not display without the space. It gives an improper javascript error. This whole article will include a space after each less than sign, because any less than sign with any other character connected to it will give an error when this article is published. You must remove the space between the less than sign and the following character in these examples in order for your XML to work. -
Step 2
A simple XML doc< ?xml version="1.0">
< library>
< book>
< title>Think and Grow Rich< /title>
< author>Napoleon Hill< /author>
< description>This book is about ...< /description>
< /book>
< /library>
* Remember to remove the space between the < and the following character.
This is a simple XML document. The library tag is the root element because it holds all the other data. Notice the tree structure. It can go as deep as you want it to, and you can name the tags anything you want. That is what we mean by self-descriptive. Instead of library you can name it anything (catalog, magazine, main, root).
The book tag is called a child element. It is a child of the root element library. The title, author, and description are sub child elements of library and child elements of book. As you can see, it is just like HTML in the sense that there are closing tags. -
Step 3
XML Attribute< book type="new">
Your elements can contain descriptions called attributes. In this example book is describe as new. There can be another book that has a type="used", by using attributes like this one, you will easily be able to categorize your books by used or new later on. -
Step 4
Now that you know how to write XML, you should probably learn how to display the XML data. Please look at our eHow article on displaying XML =>












