eHow launches Android app: Get the best of eHow on the go.

How To

How to Write XML Files

Member
By klickitmedia
User-Submitted Article
(0 Ratings)
XML
XML
www.KlickItMedia.com

XML (EXtensible Markup Language) is a very easy programming language to write. It's only purpose is to transport and store data into hierarchical structures. XML is self-descriptive meaning that you can name the tags anything you like. It is similar to HTML in appearance, but it does not display data. It took me a while to get the previous statement. It does NOT display data. For this you must use a programming language like php or javascript to pull and display the XML data. Since the purpose of this article is to write XML, this is the only thing we will be discussing. Look for how to display XML data in the related links.

Difficulty: Easy
Instructions
  1. Step 1
    XML open tag
     
    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.

  2. Step 2
    A simple XML doc
     
    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.

  3. Step 3
    XML Attribute
     
    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.

  4. 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 =>

Tips & Warnings
  • Remember you need to remove the white space between the less than sign and the following character. eHow will not let the article publish without this space, and the XML will not be valid if you do not remove it.
Resources
Subscribe

Post a Comment

Post a Comment

eHow Article: How to Write XML Files

Related Ads

  • Have you done this? Click here to let us know.
I Did This
Tags
Get Free Internet Newsletters

Copyright © 1999-2009 eHow, Inc. Use of this web site constitutes acceptance of the eHow Terms of Use and Privacy Policy.   en-US Portions of this page are modifications based on work created and shared by Google and used according to terms described in the Creative Commons 3.0 Attribution License.

Demand Media
eHow_eHow Technology and Electronics