0% found this document useful (0 votes)
13 views

Lect7-8 - XML

This document provides an introduction to XML, including: XML is a markup language like HTML used to carry structured data rather than display it. It allows users to define their own element tags. XML is a standard developed by W3C to encode documents in a machine-readable format and simplify data sharing and transport. Key XML components include elements, tags, attributes, and comments. XML has a tree structure and uses syntax rules to ensure valid documents.

Uploaded by

siddiqadil2
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
13 views

Lect7-8 - XML

This document provides an introduction to XML, including: XML is a markup language like HTML used to carry structured data rather than display it. It allows users to define their own element tags. XML is a standard developed by W3C to encode documents in a machine-readable format and simplify data sharing and transport. Key XML components include elements, tags, attributes, and comments. XML has a tree structure and uses syntax rules to ensure valid documents.

Uploaded by

siddiqadil2
Copyright
© © All Rights Reserved
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 14

Web Engineering

CSI-654

Extensible Markup Language

(XML)
XML
Introduction
 A markup language much like HTML
 A simple text based format for representing structured information, documents, data,
configuration, books, transactions, invoices etc.
 It was designed to carry data, not to display data
 Designed to transport and store data, with focus on what data is………
 The tags are not predefined. One must define their own tags
 It is a software- and hardware-independent tool for carrying information
 It is the set of rules for encoding documents in machine readable form. It is defined in
the XML 1.0 specification produced by the world wide consortium (W3C)
 A tool for data transmissions between all sorts of applications
 It is designed to be self-descriptive
 It is a (W3C) recommendation
 It is not a replacement for HTML
 As of 2009, hundreds of XML based languages have been developed including
RSS (Really Simple Syndication), Atom, SOAP(Simple Object Access Protocol ) and
XHTML
Why study XML?

• XML plays an important role in many different IT systems.


• XML is often used for distributing data over the Internet.
• It is important (for all types of software developers!) to have a good
understanding of XML.
Important XML standards
• XML AJAX
• XML DOM
• XML XPath
• XML XSLT
• XML XQuery
• XML DTD
• XML Schema
• XML Services
The Difference Between XML and
HTML
XML and HTML were designed with different goals:
•XML was designed to carry data - with focus on what data is.
•HTML was designed to display data - with focus on how data looks.
•XML tags are not predefined like HTML tags are.

XML Simplifies Things


•It simplifies data sharing
•It simplifies data transport
•It simplifies platform changes
•It simplifies data availability

XML became a W3C Recommendation as early as in February 1998.


XML components
Syntax Rules
• Declaration
• Tags
• Elements
• Attributes
• Comments
Declaration
• First line in document.
<?xml Version=‘1.0’?>
• Provide information to the parser
<menu>
• Recommended but optional. <items>
• Contains three name-value pairs: <itemname>soup</itemname>
• Version <cost>300</cost>
• Encoding (defaults to UTF-8) </item>
</menu>
• Standalone (rare)
XML tags, elements and
attributes
All XML Elements Must Have a Closing Tag
<myname>This is a paragraph</myname>

Tags are Case Sensitive


<Message>This is incorrect</message>
<message>This is correct</message>

Elements Must be Properly Nested


<b><i>This text is bold and italic</b></i>
<b><i>This text is bold and italic</i></b>

Documents Must Have a Root Element


XML documents must contain one element that is the parent of all other elements. This
element is called the root element.
<root>
<child>
<subchild>.....</subchild>
</child>
</root>
Attribute Values Must be Quoted
<note date=“12/11/2007”></note>

Entity References
Some characters have a special meaning in XML, like "<" inside an XML element, it will
generate an error because the parser interprets it as the start of a new element.

This will generate an XML error


<message>if salary < 1000 then</message>

To avoid this error, replace the "<" character with an entity reference
<message>if salary &lt; 1000 then</message>

There are 5 predefined entity references in XML &lt; < less than
Only the characters "<" and "&" are strictly illegal in XML
&gt; > greater than
&amp; & ampersand
&apos; ' apostrophe
&quot; " quotation mark
Comments
<!-- This is a comment -->
XML Stores New Line as LF

XML Naming Rules


•XML elements must follow these naming rules:
•Element names are case-sensitive
•Element names must start with a letter or underscore
•Element names cannot start with the letters xml (or XML, or Xml, etc)
•Element names can contain letters, digits, hyphens, underscores, and periods
•Element names cannot contain spaces
•Any name can be used, no words are reserved (except xml).
XML Tree Structure
XML
<?xml version="1.0"?>

<person>

<name>
<firstname>Ahmed</firstname>
<lastname>Ali</lastname>
</name>

<job>Engineer</job>

<gender>Male</gender>
</person>

One.xml
XML
person
<?xml version="1.0"?> {
<?xml-stylesheet type="text/css“ background-color:#ccff00;
href=“myone.css"?> font-family:century gothic,arial,sans-serif;
<person> }
<name> job
<firstname>Ahmed</firstname> {
<lastname>Ali</lastname> display:block;
</name> font-family:arial
}
<job>Engineer</job>
gender
<gender>Male</gender> {
</person> font-family:arial black;color:red;

One.xml myone.css
Advantages of using XML
• Simpler version of Standard Generalized Markup Language (SGML).
• Easy to understand and read.
• Supported by a large number of platforms.
• Used across open standards.
THE END

You might also like