You are on page 1of 17

XML

Softsmith Infotech
XML
EXtensible Markup Language
XML is a markup language much
like HTML
Designed to carry data, not to
display data
XML tags are not predefined. You
must define your own tags
Self-descriptive
W3C Recommendation
Softsmith Infotech
Overview
Comparing HTML and XML
XML
DTD
XSD
XSL
Tags
Naming convention
Usage
Parsing

Softsmith Infotech
HTML and XML
HTML
Display data
How data looks?
XML
Store and Retrieve data
What data is?

Softsmith Infotech
XML Usage
To display html contents, dynamically
Helps to store data that has no
compatibility issues
Simplifies data transfer
Platform independent

Softsmith Infotech
XML Format
Similar to HTML
Has start tags and end tags
Strict nesting (every start tag should have an
end tag)
<root>
<child>
<sub-child>.....</sub-child>
</child>
</root>

Softsmith Infotech
XML Tags
Every start tag should have an end tag
Tag names are case sensitive
Attribute values should be enclosed in
quotes
XML documents should have a root
element
XML tags should be properly nested

Softsmith Infotech
XML Special characters
&lt
&gt
&amp
&apos
&quot

XML Whitespace is preserved

Softsmith Infotech
Comments in XML
<!-- - Start
- -> End

Similar to HTML

Softsmith Infotech
XML Naming Rules
Names can contain letters, numbers,
and other characters
Names must not start with a number
or punctuation character
Names must not start with the
letters xml (or XML, or Xml, etc)
Names cannot contain spaces

Softsmith Infotech
Best Naming Practices
Make names descriptive. Names with an underscore separator are nice:
<first_name>, <last_name>.
Names should be short and simple, like this: <book_title> not like this:
<the_title_of_the_book>.
Avoid "-" characters. If you name something "first-name," some software
may think you want to subtract name from first.
Avoid "." characters. If you name something "first.name," some software
may think that "name" is a property of the object "first."
Avoid ":" characters. Colons are reserved to be used for something called
namespaces (more later).
XML documents often have a corresponding database. A good practice is to
use the naming rules of your database for the elements in the XML
documents.
Non-English letters like are perfectly legal in XML, but watch out for
problems if your software vendor doesn't support them.

Softsmith Infotech
XML Attributes limitation
Attributes cannot contain multiple
values
Attributes cannot contain tree
structures
Attributes are not easily expandable

Softsmith Infotech
XML types
Well formed XML - XML written with
correct syntax

Valid XML A well formed XML which also


conforms to the rules of DTD (Document
type definition) or an XSD (XML Schema
definition)

Softsmith Infotech
DTD
Document Type Definition

Tells how an XML document is to be


structured

Used by XML Parser to check for the


validity of XML document

Softsmith Infotech
XSD
XML Schema Definition

Similar to DTD, but more powerful than it

Tells the parser, what are the elements


that an xml document will contain and
what data type do each element belongs
to
Softsmith Infotech
XSL
Extensible Style sheet Language
Similar to CSS for HTML
Defines styles for an xml document
Controls the format of XML tag
XML document will be displayed in a raw
way in the browser. That is with and +
symbols
XSL makes XML document more appealing

Softsmith Infotech
XML Parsers
Two parsers available for XML
SAX
Simple API for XML
Reads XML document serially
DOM
Document Object Model
Treats every XML tag as an element or object with in a
document
Can access each tag as Document.Node or
Document.ParentElement
Available in .Net framework

Softsmith Infotech

You might also like