PGDEL/DECP03/Unit3/14

From WikiEducator
< PGDEL‎ | DECP03‎ | Unit3
Jump to: navigation, search



Unit 3.3 Web application development tools & Technologies
XML element naming rules

XML elements must follow these naming rules:           

           1. Names can contain letters, numbers, and other characters
           2. Names cannot start with a number or punctuation character
           3. Names cannot start with the letters xml (or XML, or Xml, etc)
           4. Names cannot contain spaces
           5. Any name can be used, no words are reserved.

Important rules to keep in mind while creating XML document
Rule
Wrong Right

XML document should be well formed,

end tag must have the same name as the start tag.

<contact-detail>
<name> Aakash
</contact-detail> </name>

<contact-detail> <name> Aakash

</name> </contact-detail>

XML Document must be only one root element.
<contact-detail1> <name> Aakash Rathore </name> </contact-detail1>
<contact-detail2> <name> Naresh Kumar </name> </contact-detail2>
<contact-detail>
<name> Aakash Rathore </name>
<name> Naresh Kumar </name>
</contact-detail>

XML is case sensitive, so be aware about the name of tags.      It will generate parser error because name and NAME are different.

<name> Aakash Rathore </contact-detail> </NAME>
<name> Aakash Rathore </contact-detail> </name>
XML attribute value must be quoted.Date is an attribute of XML element <contact-detail>
<contact-detail date=02/05/2012>
<name> Aakash Rathore </name>
<company> ABC Ltd. </company>
<phone> 234567 </phone>
</contact-detail>
<contact-detail date=”02/05/2012”>
<name> Aakash Rathore </name>
<company> ABC Ltd. </company>
<phone> 234567 </phone>
</contact-detail>
Note : White space in document is not automatically truncated.

Road Works.svg Work in progress, expect frequent changes. Help and feedback is welcome. See discussion page. Road Works.svg