|
|
| XML
Syntax illustration
Illustration 3:
<?xml version="1.0" encoding="ISO-8859-1"?>
<note date=12/11/2002>
<to>John</to>
<from>Jane</from>
</note>
|
|
The error in the first document is that the date attribute in the note
element is not quoted.
This is correct: date="12/11/2002". This is incorrect: date=12/11/2002.
With XML, white space is preserved
With XML, the white space in your document is not truncated.
This is unlike HTML. With HTML, a sentence like this:
Hello
my
name is Tove,
will be displayed like this:
Hello my name is John,
because HTML reduces multiple, consecutive white space characters to a
single white space. With XML, CR / LF is converted to LF
With XML, a new line is always stored as LF.
|
Do you know what a typewriter is? Well, a typewriter is a
mechanical device which was used last century to produce printed
documents.
After you have typed one line of text on a typewriter,
you have to manually return the printing carriage to the left margin
position and manually feed the paper up one line.
In Windows applications, a new line is normally stored as a pair of
characters:
carriage return (CR) and line feed (LF). The character pair bears some
resemblance to the typewriter actions of setting a new line. In Unix
applications, a new line is normally stored as a LF character. Macintosh
applications use only a CR character to store a new line.
Comments in XML
The syntax for writing comments in XML is similar to that of HTML.
<!-- This is a comment -->
Go To
Index
|
|
|