220 likes | 232 Views
What XML is and what it means to me as a Computer Scientist. By: Derek Edwards CS 376 March 10, 2003. XML. Overview. What is XML XML & HTML What does XML do Uses of XML XML & HTML Example XML Syntax Displaying XML Data Binding. XML stands for:. X tensible M arkup L anguage.
E N D
What XML is and what it means to me as a Computer Scientist By: Derek Edwards CS 376 March 10, 2003 XML
Overview • What is XML • XML & HTML • What does XML do • Uses of XML • XML & HTML Example • XML Syntax • Displaying XML • Data Binding
XML stands for: Xtensible Markup Language 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
XML & HTML • XML describes data • HTML displays data
What does XML do? • Nothing. • XML is just a structure that stores data
Uses of XML • Shares Data • Data is stored in a plain text format. • Lets different applications access the same information
Uses 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
Uses of XML • Creates new languages • WML (wireless markup language) is written in XML
Simple 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
Same 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
XML 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>
XML 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>
XML 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>
XML 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>
XML 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>
XML 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>
Another 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
Displaying XML • Can be displayed using a Cascading Stylesheet • Preferred method is to use Extensible Stylesheet Language (XSL) Click for online CSS file Click for CD database with CSS file
Data 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
Displaying 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 Table Using Form Buttons Simple Application
XML • Very versatile • Code is completely customizable • Display is completely customizable • Becoming widely used • Becoming more and more important • Must have at least an understanding about it