90 likes | 215 Views
Introduction to XML. Chien -Chung Shen CIS, UD cshen@cis.udel.edu. What is XML. XML = e X tensible M arkup L anguage A text-based markup language much “like” HTML Designed to transport/store data, not to display data
E N D
Introduction to XML Chien-Chung Shen CIS, UD cshen@cis.udel.edu
What is XML • XML = eXtensibleMarkup Language • A text-based markup language much “like” HTML • Designed to transport/storedata, not to display data • XML tags are not predefined - you must define your own tags (for your specific applications) • XML is designed to be self-descriptive
What is XML • Identify data using tags(identifiers enclosed in angle brackets: <...>) • Collectively, the tags are known as markup • XML tags identify the data rather than specify how to display it • An XML tag acts like a field name - specifying the semantics (meaning) of the data
Difference between XML and HTML • XML is not a replacement for HTML • XML and HTML were designed with different goals: • XML was designed to transport and store data, with focus on what data is • HTML was designed to display data, with focus on how data looks • HTML is about displaying information, while XML is about carryinginformation • Try http://www.cis.udel.edu/~cshen/367/html.html
XML Does Not DoAnything • XML was created to structure, store, and transport information • The following example is a note to Alice, from Bob, stored as XML: <note> <to>Alice</to> <from>Bob</from> <subject>Greetings</subject> <body>Happy New Year of the Snake!!!</body> </note> • Self-descriptive • Just information wrapped in tags – someone has to write some software to send, receive or display it
Tags and Attributes • Tags can also contain attributes —additional information included as part of the tag itself, within the tag’s angle brackets <message to=“you@yourAddress.com” from=“me@myAddress.com” subject=“XML is cool”> <text>Let me tell you why ... </text> </message> • attribute name = attribute value
With XML You Invent Your Own Tags • XML has no predefined tags - tags in the example above (like <to> and <from>) are not defined in any XML standard; these tags are "invented" by the author of the XML document • Tags used in HTML are predefined - HTML documents can only use tags defined in the HTML standard
XML is Not a Replacement for HTML • XML is a complement to HTML • In most web applications, XML is used to transport data, while HTML is used to format and display the data • XML is a software- and hardware-independent tool for carrying (transport/store) information • e.g., Simple Object Access Protocol (SOAP) uses XML (http://en.wikipedia.org/wiki/SOAP)
Use of XML for Android • AndroidManifest.xml- Every application must have this file (with precisely that name) in its root directory, which presents essential information about the application to the Android system • Declare UI elements in XML- Android provides a straightforward XML vocabulary (tags) that corresponds to the View classes and subclasses, such as those for widgets and layouts