(XML Tree)
Example:
The image above represents one book in the XML below:
|
The root element in the example is
The
----------------------------------------------------------------
XML Tags are Case Sensitive
Entity References
Some characters have a special meaning in XML.
If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element.
This will generate an XML error:
To avoid this error, replace the "<" character with an entity reference:
There are 5 predefined entity references in XML:
< | < | less than |
> | > | greater than |
& | & | ampersand |
' | ' | apostrophe |
" | " | quotation mark |
Note: Only the characters "<" and "&" are strictly illegal in XML. The greater than character is legal, but it is a good habit to replace it.
--------------------------XML Naming Rules
XML elements must follow these naming rules:
- Names can contain letters, numbers, and other characters
- Names cannot start with a number or punctuation character
- Names cannot start with the letters xml (or XML, or Xml, etc)
- Names cannot contain spaces
Any name can be used, no words are reserved.
---------------------------------------
XML Elements are Extensible
XML elements can be extended to carry more information.
Look at the following XML example:
Don't forget me this weekend! |
Let's imagine that we created an application that extracted the
MESSAGE To: Tove
Don't forget me this weekend! |
Imagine that the author of the XML document added some extra information to it:
Don't forget me this weekend! |
Should the application break or crash?
No. The application should still be able to find the
Comments