how create xml file - comment in xml file

xml prolog .

the first part of a document is the is optional.

the XML syntax :

<?xml version="1.0"?>

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

<?xml version="1.0"     encoding="utf-8"    standalone='yes/no'?>

the prolog declaration contains only one piece of information about version number and encoding used in the document.

encoding :- encoding is the process of turning characters into their equivalent binary representation.

if the standalone attribute is included in the xml declaration, it must be set to either 'yes' or 'no'.

xml document must have a root element.

the next step after writing the prolog is creating the root element.all documents must have one and only one root element.

                                  <subchild> content </subchild>                                  

when we declare element in xml document, we must follow some basic rules.

xml tags must have a closing tag.

<name> my name is sandeep </name>

<img />      empty tags.

xml tags are case sensitive.

all xml elements are case sensitive.this means that <first> is different from <first>,which is different from <first>.

<name>this is correct </name>

<name>this is incorrect </name>

<name>this is incorrect </name>

xml elements must be properly nested

all xml elements must be properly nested within each other.

<p><span> this is span first it closed</span> </p>

xml attribute values must be quoted.

attributes are simple name/value pairs associated with an element.they are attached to the start-tag, but not to xml the attribute values must be quoted(either single ' ' or double "").

attributes are unordered.

shown in the following code :-

                    <programmer  name ="sandeep" >     this is legal code 
                          <company>infosys </company>                       
                    <programmer  name = 'sandeep' >     this is legal code 
                          <company>infosys </company>                       
                    <programmer  name = sandeep" >     this is wrong code 
                          <company>infosys </company>                       
                    <programmer  name = 'sandeep" >     this is wrong code 
                          <company>infosys </company>                       

comments in xml file

the comments in xml file are used to increase readability of xml code, its not executable.

note :- comments cannot appear before the xml declaration.

XML comment syntax <!-- some text putting here -->

                            <java>i live java book </java>
                                <!-- but i not like the all other java books so not tell me question -->
                            <php> the php book </php>

 <!-- the php is scripting language its your first choice when you develope a website -- >

entity references

some characters have a special meaning in xml .in following table look the some predefined entity references in xml.

&gt;>greater than symbol.
&lt;<less than symbol.
&quot;"double quotation mark.

if you place the entity inside an xml element,it will generate an to avoid errors, we can use these entity for a specified entity symbol.

                       <weight> 100kg is > 50kg </weight>     this will generate the error.

to avoid this error,we can replace this ">" symbol with an entity reference.

                       <weight> 100kg is &gt; 50kg </weight>     this will generate the error.