View
239
Download
1
Category
Tags:
Preview:
Citation preview
XMLXML
XMLXML
What XML is and what it means
to me as aComputer Scientist
By: Derek EdwardsCS 376
March 10, 2003
XMLXML
OverviewOverview
• What is XML• XML & HTML• What does XML do• Uses of XML• XML & HTML Example• XML Syntax• Displaying XML• Data Binding
XMLXML
What is XML?What is XML?
• Very similar to HTML• Designed to describe data• No predefined tags like in HTML• Uses a Document Type Definition
(DTD) or an XML Schema to describe data
XMLXML
Uses of XMLUses of XML
• Shares Data– Data is stored in a plain text format.– Lets different applications access
the same information
XMLXML
Uses of XMLUses of XML
• Stores data– Used widely in database systems
and file systems to store data– Applications can then be written to
retrieve the stored data– Another application can then display
the text in a certain way
XMLXML
Uses of XMLUses of XML
• Creates new languages– WML (wireless markup language) is
written in XML
XMLXML
Simple HTML fileSimple HTML file
<html><head>
<title>note</title></head><body>
<p>To: John<p>From: Frank<p>Subject: Reminder<p>Message: Don’t forget the money you owe me
</body></html>
Click here for online file
XMLXML
Same file in XMLSame file in XML
<?xml version=“1.0” encoding=“ISO-8859-1”?><note><to>John</to><from>Frank</from><subject>Reminder</subject><msg>Don’t forget the money you owe me </msg></note>
Click here for online file
XMLXML
XML File Line by LineXML File Line by Line
<?xml version=“1.0” encoding=“ISO-8859-1”?><note><to>John</to><from>Frank</from><subject>Reminder</subject><msg>Don’t forget the money you owe me </msg></note>_______________________________________________
• XML declaration line, defines version and the character type
• Same as: <html> · · · · · </html>
XMLXML
XML File Line by LineXML File Line by Line
<?xml version=“1.0” encoding=“ISO-8859-1”?><note><to>John</to><from>Frank</from><subject>Reminder</subject><msg>Don’t forget the money you owe me </msg></note>_______________________________________________
• Describes the root element in the file• “This document is a note”• Same as: <body> · · · · · </body>
XMLXML
XML File Line by LineXML File Line by Line
<?xml version=“1.0” encoding=“ISO-8859-1”?><note><to>John</to><from>Frank</from><subject>Reminder</subject><msg>Don’t forget the money you owe me </msg></note>_______________________________________________
• The child elements in the file• Same as: <p> · · · · · </p>
XMLXML
XML SyntaxXML Syntax
• All XML tags must have opening and closing tags
• All tags are case sensitive
HTML<p>This is paragraph 1…<P>This is paragraph 2...XML<p>This is paragraph 1...</p><P>This is paragraph 2...</P>
XMLXML
XML SyntaxXML Syntax
• All XML tags must be nested properly
HTML<b><I>This is bold & italic</b></I>XML<b><I>This is bold & italic</I></b>
XMLXML
XML SyntaxXML Syntax
• Only one root element allowed<note><to>John</to><from>Frank</from><subject>Reminder</subject><msg>Don’t forget the money you owe me </msg></note><note> · ·</note>
XMLXML
Another XML ExampleAnother XML Example
<CATALOG> <CD>
<TITLE>Empire Burlesque</TITLE>
<ARTIST>Bob Dylan</ARTIST>
<COUNTRY>USA</COUNTRY>
<COMPANY>Columbia</COMPANY>
<PRICE>10.90</PRICE>
<YEAR>1985</YEAR>
</CD>
<CD>Click for cd.xml
XMLXML
Displaying XMLDisplaying XML
• Can be displayed using a Cascading Stylesheet
• Preferred method is to use Extensible Stylesheet Language (XSL)
Click for online CSS fileClick for CD database with CSS file
XMLXML
Data Binding in XMLData Binding in XML
• “Data Islands” can be bound to HTML elements (like HTML Tables)
<html><body>
<xml id="cdcat" src="cd.xml"></xml><table border="1" datasrc="#cdcat"><tr>
<td><span datafld="ARTIST"></span></td><td><span datafld="TITLE"></span></td>
</tr></table>
</body></html>Click for online version
XMLXML
Displaying XML AgainDisplaying XML Again
• Endless ways to display XML• CD Database Example using <THEAD> and
<TFOOT> tags• Another rendering of the CD Database• CD Database using form elements and
JavaScript• Simple application for the CD Database
Using <THEAD> and <TFOOT>Full Rendering in TableUsing Form ButtonsSimple Application
Recommended