RSS Feed
Download our iPhone app
Browse DevX
Sign up for e-mail newsletters from DevX


XML Documents : Page 4

XML documents are similar to HTML documents. They contain information and markup tags that define the information, and are saved as ASCII text.

Well-formed XML
A document that conforms to the XML syntax rules is called "well-formed." If all your tags are correctly formed and follow XML guidelines, then your document is considered a well-formed XML document. That's one of the nice things about XML—you don't need to have a DTD in order to use it.

Begin the Well-formed Document
To begin a well-formed document, type the XML declaration:

<?xml version="1.0" standalone="yes" encoding="UTF-8"?>

If you are embedding XML, it will go after the <HTML> and <HEAD> tags, and before any Javascript.

If you are creating an XML-only document, it will be the first thing in the file.

You must include the version attribute for the XML declaration. The version is currently "1.0." Defining the version lets the browser know that the document that follows is an XML document, using XML 1.0 structure and syntax.

The next step is to declare that the document "stands alone." The application that is processing this document knows that it doesn't need to look for a DTD and validate the XML tags.

Finally, declare the encoding of the document. In this case, the encoding is UTF-8, which is the default encoding for XML. You can leave off this attribute and the processor will default to UTF-8.

Remember the Root Element
After the declaration, enter the tag for the root element of your document. This is the top-most element, under which all elements are grouped.

Follow XML Syntax
Now, enter the rest of the your content. Remember to follow XML syntax:
  • Remember that capitalization matters;
  • Quote all attribute values;
  • Close all tags;
  • Remember to close empty tags too, like this:


Pretty easy, isn't it? That's all there is to it!

Close Icon
Thanks for your registration, follow us on our social networks to keep up-to-date