Chapter 4 XML
Chapter 4 XML
XML
What is XML?
• The eXtensible Markup Language (XML) is a text
document used mainly for distributing the data
on the internet between different applications.
• An xml is a text file saved with an extension .xml
• It’s a document for storing and transporting the
data; mainly used for the interchanging the data
on the internet.
• It is a language similar to html.
• In xml user can define our own tags and these
tags are used to describe the data.
• It is a compatible scripting language.
Advantages
• xml documents are easy to create.
• It has the property of self describing the data.
• xml is a fully compatible application like java.
• It is a portable language.
• It is platform independent.
*Difference between XML and HTML
XML syntax:
XML declaration:
• A simple Type
• A complex type
• “SIMPLE” TYPE ELEMENTS
• A simple element is an XML element that can contain
only text. It cannot contain any other elements or
attributes.
• Simple type elements have no children or attributes.
• Eg: <xs:element _name=“hai”/>
• “COMPLEX” TYPE ELEMENTS
• – A complex element may have attributes
•A complex element is an XML element that contains
other elements and/or attributes.
• – A complex element may be empty, or it may
contain text, other elements, or both text and other
elements.
• Eg: <product pid="1345"/>
Simple Elements
• A simple element is an XML element that can
contain only text. It cannot contain any other
elements or attributes.
• Complex Elements
A complex element is an XML element that
contains other elements and/or attributes.
• There are four kinds of complex elements:
• Empty elements
<product pid="1345"/>
Which does not have a child element.
• Elements that contain only other elements OR CHILD
Ex:A complex XML element, "employee", which
contains only other elements:
<employee>
<firstname>John</firstname>
<lastname>Smith</lastname>
</employee>
• Elements that contain only text.
Ex: A complex XML element, "food", which
contains only text:
<food type="dessert">Ice cream</food>
• Elements that contain both other elements and
text
Ex:A complex XML element, "description",
which contains both elements and text:
<description>
It happened on <date>03.03.99</date>
....
</description>
**XSL( Extensible Style sheet Language)