Download - By Mohsen ashouri. Introduction Comparison between XML and HTML XML Syntax Challenges Summary
ByMohsen ashouri
Introduction Comparison between XML and HTML XML Syntax Challenges Summary
eXtensible Markup Language Based on Standard Generalized Markup
Language (SGML) Version 1.0 introduced by World Wide
Web Consortium (W3C) in 1998 Bridge for data exchange on
the Web
Extensible set of tags
Content orientated errors are not
allowed Allows multiple
output forms
Fixed set of tags Presentation
oriented Ignore many HTML
errors Single presentation
XML HTML
An XML element is made up of a start tag, an end tag, and data in between.
Example: <director> Majid Majidi </director> Example of another element with the same value: <actor> Parviz Parastooi</actor> XML tags are case-sensitive: <CITY> <City> <city> XML can abbreviate empty elements, for example: <Book> </Book> can be abbreviated to <Book/>
An attribute is a name-value pair separated by an equal sign (=).
Example: <City City_IP=“94608”> Isfahan
</City> Attributes are used to attach additional,
secondary information to an element.
A basic XML document is an XML element that can, but might not, include nested XML elements.
Example: <books> <book isbn=“123”> <title> Second Chance </title> <author> Matthew Dunn
</author> </book> </books>
<BOOKS><book id=“123”
loc=“library”> <author>Hull</author> <title>California</title> <year> 1995 </year></book><article id=“555”
ref=“123”> <author>Su</author> <title>
Venezuela</title></article></BOOKS> Hull Purdue
BOOKS
123 555
California
Su
titleauthor
title
author
articlebook
year
1995
ref
loc=“library”
Authoring guidelines:› All elements must have an end tag.
› Elements must be properly nested, e.g. not
<book><title>book and title</book></title>
› All attribute values must be enclosed in quotation marks.
› Each document must have a unique first element, the root node.
Comments can be put anywhere in an XML document
Comments are not elements and do not have an end tag
The blanks after <!-- and before --> are optional The closing bracket must be --> Comments are not displayed by browsers, but can
be seen by anyone who looks at the source code Example : <!-- This is a comment in both HTML and XML
-->
An XML document may have an optional DTD.
DTD serves as grammar for the underlying XML document, and it is part of XML language.
DTDs are somewhat unsatisfactory, but no consensus exists so far beyond the basic DTDs.
DTD has the form: <!DOCTYPE root [markupdeclaration]>
Consider an XML document:
<db> <person> <name>Ali</name> <age>42</age> <email>[email protected]
</email> </person> <person>………</person> ………. </db>
db
Person
42
age
name email
Person
Person
…
ali
DTD for it might be: <!DOCTYPE db [ <!ELEMENT db (person*)> <!ELEMENT person (name, age,
email)> <!ELEMENT name (#PCDATA)> <!ELEMENT age (#PCDATA)> <!ELEMENT email (#PCDATA)> ]>
If the elements within your document must appear in a distinct order, you should define your content model using a sequence.
To achieve this, simply list the element names separated by commas.
Example:› <!ELEMENT name (first, middle,
last)>
Example:› <!ELEMENT item (CD| cassette| record|MP3)>
› This declaration mandates that we would allow our <item> element to contain one <cd> or one <cassette> or one <record> or one <MP3>
› If <item> element were empty, or if it contained more than one of these the parser would raise an error.
Occurrence Indicator:
Indicator Occurrence
(no indicator) Required One and only one
? Optional None or one
* Optional, repeatable
None, one, or more
+ Required, repeatable
One or more
Learn XML – Persian Language
Security