BYU Home page BRIGHAM YOUNG UNIVERSITY  
Search BYU 
General XML Fundamentals
Table of Contents
Go Down to Content

    General XML Fundamentals is a short list explaining several important aspects of XML, with special emphasis on when XML differs from HTML.

    The six things you must know about XML...

    1Every bit of information in an xml document is wrapped in tags.
    Every bit of information in an xml document is wrapped in tags. Tags describe content within xml files. Check out these examples:

    <tag> Information within the tag </tag>

    <text> This part of the content is described as text </text>

    <related-page> This part of the content is described as a related page </related-page>

    2Each piece of information must be wrapped in a starting and ending xml tag.
    Each piece of information must be wrapped in a starting and ending xml tag. XML will complain about this:

    <text> Oh no! No ending tag!

    If you know HTML, be careful: XML differs from HTML on this point. Where HTML browsers often handle missing closing tags perfectly and in many cases expects them, XML will always complain when a tag does not open and close.

    3There must be a single outer-most tag.
    There must be a single outer-most tag. You can't have this:

    <tag> Arghhh! Two outer-most tags! </tag>
    <tag> Arghhh! Two outer-most tags! </tag>


    Instead you need something like this:

    <outer-tag>
    <tag> Hurrah! The 'outer-tag' saves the day! </tag>
    <tag> Hurrah! The 'outer-tag' saves the day! </tag>
    </outer-tag>


    Note: In the ECEn XML Web Templates, the <page> ... </page> tag will usually be your outermost tag and wrap around everything.

    4There are two characters you can only type with special codes: '&' and '<'.
    There are two characters you can only type with special codes: '&' and '<'. If you want an '&' or a '<' to show up on your page, you need to type '&amp;' (without the single quotes; think of 'ampersand') or '&lt;' (without the single quotes; think of 'less than'), respectively.

    5XML is case-sensitive.
    XML is case-sensitive. For example, this is valid XML:

    <TEXT>This is my text.</TEXT>

    ...but it's not the same as this:

    <text>This is my text.</text>

    The ECEn Web Templates tags are all in lower case, so they won't render the content of <TEXT> tags as they would the content of <text> tags---as far as XML is concerned, those are two completely different tags.

    Understanding that XML treats <TEXT> and <text> explains why XML would complain about something like this:

    <TEXT>This is my text.</text>

    Here XML sees an opening tag with no closing tag and a closing tag with no opening tag, and since everything in XML must be enclosed in matching opening and closing tags, this is not valid XML.

    If you know HTML, you probably know that HTML is not case-sensitive.

    6There is more than one way to create an empty tag.
    Tags do not need to contain any information to be valid. This is valid XML:

    <line-break></line-break>

    XML has a short hand way to represent a single empty tag:

    <line-break/>

    These two representations are equivalent, so feel free to use whichever you prefer when you insert an empty tag.

    Maintained by The ECEn Web Team. Based on v. 3.8 of the ECEn web templates (view XML, live XML, see other formats).
    Copyright © 1994-2005. Brigham Young University. All Rights Reserved.