Example 1 - A well-formed XML document: <?xml version="1.0" standalone="no"?> <Mail> <From>Author</From> <To>Receiver</To> <Date> Thu, 7 Oct 1999 11:15:16 -0600</Date> <Subject>XML Introduction</Subject> <body><p>Thanks for reading<Br/> this article</p> <br/> <p>Hope you enjoyed this article</p> </body> </Mail>
The first line is the XML declaration and it identifies what follows as XML code. It is called the prolog. The attribute version indicates the version of the XML standard. The statement standalone="no" indicates that markup declarations are external to the document. The XML declaration can be considered as a "processing instruction". Though this declaration is not compulsory, it is better to include such declaration. This will increase the portability of the document. Example 2 - A valid XML document conforming to mail.dtd. Date element is missing because it is optional in the mail DTD The element P has the attribute justify. After the Body and before P Comments text is allowed, because DTD allows the use of plain text in the Body element.
Example 3 - A valid XML document conforming to "mail.dtd". Date element and Cc elements are present The element P has the attribute right.
An XML document can have comments. XML's comment syntax is similar to that of HTML. Any text, except double hyphen, "--", can be placed between <-- and --> tags. Processing instruction(PI) can be embedded in the documents. The data components of the PI should be recognized by the processing applications. Publishers may want to include some codes that should not be parsed by the parsers. Those codes can be put in to the ignored sections. An ignored section will have the syntax like this:
In simple words, any ignored sections start with <[CDATA[ and end with ]]>
blog comments powered by Disqus |
|
|
|
|
|
|
|