<name age="29" sex="M" looks="good">
<name age="29" sex="M" looks="good">kenny</name>
<name first="Kenny" age="29" sex="M" looks="good" />
<person age="29" sex="M" looks="good">
<!CDATA[note:CDATA sections are transfered
- marks the boundries of an element. The tag is:
- always delimited with
< tagname >
must be a qualified xml tag name - begin with a number or
xml in any case
- is case sensitive -
<name></name> but not
- can not contain spaces within the name - spaces indicate attributes.
There are two types of tags. The open tag and the close tag.
The Open Tag - can contain attributes in name/value pairs e.g.
name= . Attribute values must be contained in quotes if there is spaces in the value. However, it is a good idea to contain all values in quotes. e.g.
name="Kenny" are both valid. However
name=Kenny L would throw a parse error and need to be contained in quotes i.e.
The open tag can also contain namespace references. Namesspace references indicated a seperate document that defines the specifics about the tag.
The Closing Tag - encased in
< > but the name begins with a slash
/. The name MUST be the same as the open tag (case sensitive). e.g.
is made up of a set of tags that may or may not encase data. There are two kinds of elements. The element and the empty element. An empty element has no data. In the interest of saving bytes, the empty element may omit the closing tag but not the slash.
The empty element: make the data an attribute
Elements can be nested but not overlapped. Empty elements can not have children (other elements nested inside). In this example
person could be an empty element but it would have to dump it's kids.
- To reference
key characters like (
<) an entity reference must be used so that the parser doesn't get confused. An entity reference begins with an ampersand
and ends with a semi-colon
. For example:
< would make the
< symbol (lt = LessThan), and
> would make the
Sometimes entity references can become messy... an ocean of &'s. For this reason the CDATA section transferes all data