Hello friends,
welcome again..... in this section, we are going to discuss about XML.
XML is a structured language using which we can store the data in a structered manner.
advantage of XML is there are no predefined key words to store the data, user can use his own key words.
data should be stored in start and end tags .
there are two types of tags in XML
1. Simple tag
2.complex tag
simple tag contains directly data inside it
<name>Vijay</name>
complex tag contains other tags inside it
<address>
<city>Adilaad</city>
<State>AP</state>
</address>
we should ensure that each start tag has and end tag. to define the well formed ness of the xml document, we can use either dtds or xsds.
dtd stands for document type definition. using dtd, we can specify the structure of the xml document.
below is the syntax to define the simple tag in dtd
<!Element elementname(#PCDATA)>
<!Element itemcode(#PCDATA)>
<!Element itemname(#PCDATA>
below is the syntax for defining complex types
<!Element item(itemcode,itemname)>
its equilant xml tag is
<item>
<itemcode> 343</itemcode>
<itemname>test</itemname>
</item>
element names are case sensitive.
child elements should be seperated using comma.
for above xml we can write dtd as follows
<!Element item(itemcode+,itemname+)>
in above example + specifies that there should be one item code. there can be more than one also
? : specifies that there should be zero or one itemcode
* specifies that there can 0 or any number of item codes.
Disadvantage of dtd is that it is not type safe. i.e #PCDATA means we can specify either number or string.
to overcome these drawbacks, we use XSD.
read next article for XSDs.