XML Menu


XML Syntax




XML tags are as simple as in HTML but in XML tags are more flexible. There are no predefined XML tags, You must define your personalized tags (user defined tags).
The simple XML document must contain opening tag and closing tag. The XML tags are case sensitive i.e. and both tags are different. The XML tags are used to define the scope of elements in XML document. The first element of XML document is called root element.

Start Tag

The beginning of every XML element is marked by a start-tag.

Syntax
 <studyglance>

End Tag

Every element that has a start tag should end with an end-tag. The end tags include a forward slash ("/") before the name of an element.

Syntax
 </studyglance>

Empty Tag

The text that appears between start-tag and end-tag is called content. An element which has no content is termed as empty. A start-tag immediately followed by an end-tag or a complete empty-element tag is as shown below

 
<!-- empty-element -->
<studyglance> </studyglance>

<!-- A complete empty-element -->
<studyglance />

XML Prolog

The first part of a document is the prolog. It is optional so you won’t see it every time, but if it does exist it must come fi rst. The prolog begins with an XML declaration which, in its simplest form, looks like the following:

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

This declaration contains the version number, and currently this will always be either 1.0 or 1.1 and also contain information about the encoding used in the document. Here the encoding is specifi ed as UTF-8.

Comments in XML

Comments are a piece of text placed within a program to help other users to understand it, which the computer ignores when running the program. XML Comments are used as notes or lines for understanding the purpose of an XML code

Syntax
 <!-- This is a comment --> 

Comments Rules

  • Comments cannot appear before XML declaration.
  • Comments may appear anywhere in a document.
  • Comments must not appear within attribute values.
  • Comments cannot be nested inside the other comments.

Next Topic :XML Elements