Elements

printer-friendly version of this section  Print  e-mail this section  E-Mail  add a public, group or private note  Add Note  add a bookmark about this section  Add Bookmark    

Java APIs for XML Kick Start
By Aoyon Chowdhury, Parag Choudhary

Table of Contents
Appendix B.  XML: A Quick Tour


Elements constitute the bulk of the contents of an XML document. An element should be thought of as content surrounded by start and end tags. The content can either be textual data or more elements, but never both. It is also possible that an element is empty, in the sense that it does not contain any data at all. For example, consider the hubcaps element:

<hubcaps>     hub cap1 </hubcaps> 

In this element, the hubcaps element consists of the <hubcaps> start tag, the hub cap1 string as its content, and the </hubcaps> end tag. Alternatively, consider the engines element:

<engines>     <engine  type="Alpha37" capacity="2500" price="3500">         Engine 1     </engine> </engines> 

The engines element does not contain any character data as its content, but has the engine subelement as its content.

An empty element is defined in one of two ways: <element name/> or <element name></element name>. The /> is a special empty tag close delimiter. In CarParts.xml, the supplier element is an empty element.

While defining and working with elements, you need to keep the following things in mind:

  • The start and end tags must match exactly. For example, trying to close <atag> with </aTag> will result in an error.

  • A tag name must consist of at least one letter: a to z, A to Z, or even a single underscore.

  • You can have any character from the Unicode character set in a tag name.

  • There should be no spaces in a tag name. For example, <a tag> will result in errors.

  • The only valid punctuation marks are the full stop (.) and hyphen (-).


printer-friendly version of this section  Print  e-mail this section  E-Mail  add a public, group or private note  Add Note  add a bookmark about this section  Add Bookmark    
Top

[0672324342/app02lev1sec7]

 
 


JavaT APIs for XML Kick Start
JAX: Java APIs for XML Kick Start
ISBN: 0672324342
EAN: 2147483647
Year: 2002
Pages: 133

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