Syntax of An XML Element
In this article I have described about the syntax of XML application with the help of example .
XML SYNTAX
XML is a language used to describe and manipulate structured documents. XML is a flexible mechanism that accommodates the structure of specific applications.
A Simple XML Document
<?xml version="1.0" encoding="UTF-8" ?>
<greeting>WELCOME TO MCN</greeting>
|
A Simple XML Document with internal DTD
<?xml version="1.0" encoding="UTF-8" ?>
<!-- This document is valid -->
<!DOCTYPE greeting [<!ELEMENT greeting (#PCDATA)>]>
<greeting>HWELCOME TO MCN</greeting>
|
A Simple XML Document with external DTD , Comment & PI
<?xml version="1.0" encoding="UTF-8" ?>
<!-- Here is a procession instruction -->
<?render bold ?>
<!DOCTYPE greeting SYSTEM "MCN.dtd">
<greeting>WELCOME TO MCN</greeting>
|
SYNTAX RULE
There are some basic and important rule for XML syntax are as follows
- All XML elements have a closing tag.
e.g. <b>Welcom to MCN</b>
- All XML Elements should be properly nested.
e.g. <b><i>This text is bold and italic</i></b>
- Xml tags are case sensitive.
e.g. <message>Welcom to mcn</message>
- With XML, the white-space in a document is not truncated .White-space is Preserved in XML while not so in HTML.
- XML Documents Must Have a Root Element
e.g. <root>
<child>
<subchild>.....</subchild>
</child>
</root>
- XML Attribute Values Must be Quoted .
e.g. <note date="04/05/2012">
<to>ajay</to>
<from>gaurav</from>
</note>
XML Stores New Line as LF.
-
Comments in XML is same as in HTML as
<!-- This is a comment -->
Further Readings
You may also want to read these related articles :
Ask Your Question
Got a programming related question? You may want to post your question here
Programming Answers here