Open In App

XML | Syntax

Prerequisite: XML | Basics In this article, we are going to discuss XML syntax rule which is used while writing an XML document or an XML application. It is a very simple and straight forward to learn and code. Below is a complete XML document to discuss each component in detail. 




<?xml version="1.0" encoding="UTF-8"?>
<message>
   <to>Students</to>
   <from>Teacher</from>
   <subject>Regarding assignment submission</subject>
   <text>All students will have to submit assignment by tomorrow.</text>
</message>

Syntax rules for XML declaration or XML Prolog: 






<?xml version="1.0" encoding="UTF-8"?>

Below is the explanation of each point.

Syntax rules for Root Element:






<to>Students</to>
<from>Teacher</from>
<subject>Regarding assignment submission</subject>
<text>All students will have to submit assignment by tomorrow.</text>

XML Comments: Correct syntax for writing XML comments are: <!– It is comment section –>
Incorrect comments: <!– It is comment — section –> i.e. Two dashes in between the comment is not allowed.


Article Tags :