Chapter 1: Writing XML Documents
Summary
XML (eXtensible Markup Language):
- A metalanguage that allows you to create markup languages
specific to an industry or application
- Provides strict separation between content and structure.
- Enables powerful, automated manipulation of data.
- XML documents contain tags (elements) and text.
XML Elements:
- Not predefined. Each application defines its tags.
- Syntax: <ElementName> ... </ElementName>
- Case sensitive.
- End tags required.
- Empty elements allowed: <ElementName/>
- Nesting allowed.
Element Attributes:
- A piece of information defined in an element.
- A name-value pair.
- Usage: <book used="yes">
- Value must be quoted.
- Types of attributes discussed in the next chapter.
Entities:
- A piece of data with a name.
- Referred to with this syntax: &entity_name;
- May be an external file with text, graphics, video, etc.
- May be a shorthand for frequently-used phrases.
- Predefined entities:
&
<
>
"
'
Comments:
- Just like HTML comments.
- Syntax: <!-- comment text -->
CDATA:
- Tell the processor what not to process.
- Syntax:
<![CDATA[
... markup that shouldn't be processed ...
]]>
Namespaces:
- Allows you to create and use "universal" tagnames recognized
by applications in the Web.
- Syntax:
<catalog xmlns:bk="http://www.keller.com/xml/books">
<bk:book>
...
</bk:book>
...
</catalog>
- Namespaces are inherited by sub-elements.
- A document may use elements from multiple namespaces.