Download presentation
Presentation is loading. Please wait.
1
Allyson Falkner Spokane County ISD afalkner@spokanecounty.org
Introduction to XML Allyson Falkner Spokane County ISD
2
Overview Why XML? What is XML? Example XML document
General rules of well-formed XML Parts of an XML document Applications for XML
3
Why XML? SGML (Standard Generalized Markup Language)
an all encompassing markup language big and complex software to manage it is expensive. HTML (HyperText Markup Language) Simplistic no separation of style XML (eXtensible Markup Language) Flexibility of SGML Simplicity of HTML
4
What is XML? A set of rules to store and organize any information
Open Standard developed by W3C ( Unicode is it’s standard character set Separates content from style Very Structured
5
Example XML document <?xml version=“1.0”?>
<memo priority=“important”> <to>Sara</to> <subject>Reminder</subject> <message>Don't forget, <emphasize>SWIG</emphasize> tonight! <graphic fileref=“smiley.face.pict”/></message> <from>Allyson</from> </memo>
6
General rules of well-formed XML
must begin with the XML declaration must have one unique root element all start tags must match end-tags XML tags are case sensitive all elements must be closed all elements must be properly nested all attribute values must be quoted XML entities must be used for special characters
7
Parts of an XML document
Document Prolog Elements Attributes Entities Others Comments CDATA Namespaces Processing Instruction
8
Document Prolog XML declaration
Version Encoding standalone Document type declaration (root element type) Document type definition (DTD) Internal subset Entity declarations All or part of DTD
9
Elements Container element <name att1=“val1” att2=“val2”>
…content… </name> Empty element <name att1=“val1” att2=“val2”/>
10
Element Name Names can contain letters, numbers, and other characters
Names must not start with a number or punctuation character Names must not start with the letters xml (or XML or Xml ..) Names cannot contain spaces
11
Element Content element content (elements only)
simple content (text only) mixed content (both text and elements) empty content
12
Attributes name=“value”
Attribute name must be distinct within the element tag Cannot contain multiple values
13
Caution about Attributes
Only data about data should be stored as attributes because: attributes cannot contain multiple values (child elements can) attributes are not easily expandable (for future changes) attributes cannot describe structures (child elements can) attributes are more difficult to manipulate by program code attribute values are not easy to test against a DTD
14
Entities General entities Parameter entities (used in DTDs) %name;
Character entities Predefined character entities (amp, apos, gt, lt, quote) Numbered character entities (ç or ç ) Named character entities (must be predefined ISO-8879) Mixed Content entities Internal – declared in doc prolog External – in another file Unparsed entities <!ENTITIY smiley SYSTEM “/images/smile.gif” NDATA GIF> Parameter entities (used in DTDs) %name;
15
Others Comments CDATA (character data) Processing Instructions
<!– text and markup Cannot contain two dashes Cannot go before xml declaration CDATA (character data) <![ CDATA […text…]]> Processing Instructions <?name data?> Namespaces No external DTD so difficult to use Cant validate
16
Applications for XML Communicating among applications over the web
Storing databases Transforming data Repurposing data (display and use server different ways) Defining special data (math, music,graphics …) Sharing data (news paper articles, …)
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.