Element versus Tag

An element is not a tag and a tag is not an element. An element begins with a start-tag, includes some content, and then finishes with an end-tag. Tags delimit elements. They are part of elements but not themselves elements, any more than a piece of bread is a sandwich. The tags are like slices of bread. The element is the entire sandwich made up of bread, mustard and mayonnaise, meat and/or cheese. The tags are just the bread. For example, <Headline> is a start-tag. </Headline> is an end-tag. <Headline>Crowd Hears Beth Giggle</Headline> is a complete element. Elements may contain other elements. Tags may not contain other tags.

There is one degenerate case. A single empty-element tag may represent an entire element. For instance, <Headline/> is both a headline tag and a headline element. However, this is a special case. Semantically the empty-element tag is completely equivalent to the two-tag version <Headline></Headline> , and most APIs will not bother to inform you which of the two forms was actually present in the document.

In brief, the structure of an XML document is formed by nested elements. The individual elements are delimited by tags.



Effective XML. 50 Specific Ways to Improve Your XML
Effective XML: 50 Specific Ways to Improve Your XML
ISBN: 0321150406
EAN: 2147483647
Year: 2002
Pages: 144

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net