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

How To

How to Use the Doctype Tag in XML

Contributor
By eHow Contributing Writer
(0 Ratings)

XML allows users to create structure in a one-dimensional file. The file needs to be error free so any browser or other XML parser can understand it. The Document Type Definition is where the error-free specification for a perfect XML document resides. The Document Type Definition can be a separate file or it can be contained in the XML file it describes. When the Document Type Definition is in the XML file, it is contained in the DOCTYPE tag. When the Document Type Definition is in a separate file, the XML DOCTYPE tag contains a pointer, in the form of a URL, to that file. An internal Document Type Definition works well for small, simple files and external is better for complicated scenarios or where the Document Type Definition will be shared between more than one XML file.

Difficulty: Moderate
Instructions

Things You'll Need:

  • An XML parser

    Create an XML Document

  1. Step 1

    Create an XML document using either a text editor or an XML development environment. For example:
    <?xml version="1.0"?>
    <root>
    </root>

  2. Step 2

    Decide on an internal or external Document Type Definition.

  3. Use the Doctype Tag in XML

  4. Step 1

    Add the Doctype tag to your XML document. For example, if using an internal Document Type Definition, the Doctype tag for the sample XML file would look like this:
    <!DOCTYPE rootdoc [
    <!ELEMENT root (#PCDATA)>
    ]>

Tips & Warnings
  • Most modern Internet browsers have a built in XML parser and can be used to view XML files.
  • XML documents must be both valid and well formed to be interpreted correctly by an XML parser.
Subscribe

Post a Comment

Post a Comment

Related Ads

  • Have you done this? Click here to let us know.
I Did This
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. † requires javascript

Demand Media
eHow_eHow Technology and Electronics