XML
XML stands for eXtensible Markup Language.
XML is not a programming language as it does not perform
any computation or algorithms.
Programming languages have variables, conditions, loops,
etc. Hence Xml is not a programming language because
you can't use variables or conditions. It has no logic.
XML is used to store or transport data
However, as a markup language, it is used to annotate
data using tags, which interpret that data
open source language
XML
A markup language is used to provide information about a
document.
Tags are added to the document to provide the extra
information.
HTML tags tell a browser how to display the document.
XML tags give a reader some idea what some of the data
means
a meta language that allows you to create and format your
own document markups
XML documents are used to transfer data from one place
to another often over the Internet.
Difference Between HTML and XML
HTML tags have a fixed meaning and browsers know what it
is.
XML tags are different for different applications, and users
know what they mean.
HTML tags are used for display.
XML tags are used to describe documents and data.
XML is used to store or transport data, while HTML is used
to format and display the same data.
XML is a standard language which can define other
computer languages, but HTML is a predefined language
with its own implications.
XML DOCUMENT STRUCTURE
• XML Document Structure Consists of
XML Declaration
Document Type Declaration
Entity Reference
Element
Attribute
Character Data
Comments
1.The XML declaration or Prolog
– This line is called the XML prolog:
– <?xml version="1.0" encoding="UTF-8"?>
– The XML prolog is optional. If it exists, it must
come first in the document.
2. DTD
– An XML document with correct syntax is called
"Well Formed".
– An XML document validated against a DTD is both
"Well Formed" and "Valid".
3.Entity References
Some characters have a special meaning in XML.
This will generate an XML error:
<message>salary < 1000</message>
To avoid this error, replace the "<" character with
an entity reference:
<message>salary < 1000</message>
There are 5 pre-defined entity references in XML:
< < less than
> > greater than
& & ampersand
' ' apostrophe
" " quotation mark
4.XML Elements
– An XML element is everything from (including) the
element's start tag to (including) the element's end
tag.
– Syntax:
<elementname>…………</elementname>
– <price>29.99</price>
Empty XML Elements
– An element with no content is said to be empty.
– In XML, you can indicate an empty element like this:
<element></element>
OR
<element />
5. XML Attributes
Attributes are designed to contain data related
to a specific element.
Attribute values must always be quoted. Either
single or double quotes can be used.
For a person's gender, the <person> element
can be written like this:
<elementnameattributename = “Value”>
<person gender="female">
or like this:
<person gender='female'>
6. Character Data
PCDATA
– PCDATA means parsed character data.
– PCDATA is text that WILL be parsed by a parser. The text will be
examined by the parser for entities and markup.
– Tags inside the text will be treated as markup and entities will be
expanded.
CDATA
– CDATA means character data.
– CDATA is text that will NOT be parsed by a parser. Tags inside the
text will NOT be treated as markup and entities will not be
expanded.
7.Comments in XML
– The syntax for writing comments in XML is similar to that of HTML.
<!-- This is a comment -->