XML Overview - PowerPoint PPT Presentation

1 / 17
About This Presentation
Title:

XML Overview

Description:

XML is a cross-platform, software and hardware independent tool for transmitting ... A well-formed XML document has correct XML syntax ... – PowerPoint PPT presentation

Number of Views:77
Avg rating:3.0/5.0
Slides: 18
Provided by: csd86
Category:

less

Transcript and Presenter's Notes

Title: XML Overview


1
XML Overview
  • XML is a cross-platform, software and hardware
    independent tool for transmitting information.

2
What is XML?
  • Stands for Extensible Markup Language
  • Much like HTML
  • Designed to describe data
  • Tags are not pre-defined
  • Define your own
  • Designed to be self-descriptive
  • With a Document Type Definition (DTD) or XML
    Schema

3
XML vs. HTML
  • XML is not a replacement for HTML
  • Designed with different goals
  • XML designed to describe data
  • HTML designed to display data
  • XML doesnt do anything
  • Created to structure, store and send information
  • Complement to HTML
  • XML used to describe data, while HTML formats and
    displays the same data

4
Quick Examples
  • ltnotegt
  • lttogtRoselt/togt
  • ltfromgtJacklt/fromgt
  • ltheadinggtReminderlt/headinggt
  • ltbodygtStay on the lifeboat!lt/bodygt
  • lt/notegt
  • User designs own tags and document structure
  • No formatting information just meaning
  • Another example
  • http//www.upstateshakespearefestival.org/blog/rss
    /blog.php

5
How/Why to Use XML
  • Separate data from HTML
  • Store data in separate XML files
  • Use HTML to format (possibly with data island)
  • Exchange/share data among applications
  • Many B2B applications
  • Store data
  • SQL versions for XML exist
  • Make data more useful
  • Plain text is hardware, software, application
    independent no proprietary DBMS issues

6
Syntax Notes
  • Case sensitive
  • Closing tags required
  • Must have a root element
  • ltrootgt
  • ltchildgt
  • ltsubchildgt.....lt/subchildgt
  • lt/childgt
  • lt/rootgt
  • Elements and attributes (rules of thumb)

7
XML Validation
  • A well-formed XML document has correct XML syntax
  • A valid XML document conforms to a DTD or XML
    Schema
  • Why validate?
  • each of your XML files can carry a description of
    its own format with it.
  • independent groups of people can agree to use a
    common DTD or schema for interchanging data.
  • your application can use a standard DTD or schema
    to verify that the data you receive from the
    outside world is valid.
  • you can use a DTD or schema to verify your own
    data.

8
DTD Example
  • lt!DOCTYPE note
  • lt!ELEMENT note (to,from,heading,body)gt
  • lt!ELEMENT to (PCDATA)gt
  • lt!ELEMENT from (PCDATA)gt
  • lt!ELEMENT heading (PCDATA)gt
  • lt!ELEMENT body (PCDATA)gt
  • gt
  • Interpretation
  • May be internal or external to an XML file
  • Likely to be abandoned for the W3C endorsed XML
    Schema

9
XML Schema Example
  • XML-based alternative to DTD
  • Richer and more powerful than DTDs
  • lt?xml version"1.0"?gt
  • ltxsschema xmlnsxshttp//www.w3.org/2001/XMLSch
    ema
  • targetNamespace"http//www.w3schools.com"
    xmlns"http//www.w3schools.com"
    elementFormDefault"qualified"gt ltxselement
    name"note"gt
  • ltxscomplexTypegt
  • ltxssequencegt
  • ltxselement name"to" type"xsstring"/gt
  • ltxselement name"from"
    type"xsstring"/gt
  • ltxselement name"heading"
    type"xsstring"/gt
  • ltxselement name"body"
    type"xsstring"/gt
  • lt/xssequencegt lt/xscomplexTypegt
    lt/xselementgt lt/xsschemagt

10
Displaying XML
  • Examples no formatting
  • http//www.w3schools.com/xml/cd_catalog.xml
  • http//www.w3schools.com/xml/simple.xml
  • Multiple RSS examples (with or without
    stylesheets)
  • Recall no formatting information!

11
XSL
  • You can format XML for display
  • Extensible Stylesheet Language
  • Family of recommendations for defining XML
    document transformations and presentation
  • XSLT XSL Transformations
  • XSLT is a programming language on its own
  • Example
  • XML
  • XSLT (note looping structure)
  • XML with XSLT

12
Data Islands
  • An XML data island is XML data embedded into an
    HTML page
  • Uses the ltxmlgt tag
  • ltxml id"note" src"note.xml"gtlt/xmlgt
  • Not visible until data island is bound to HTML
    elements

13
Data Island Example
  • XML data http//www.w3schools.com/xml/cd_catalog.
    xml
  • Data island and binding
  • http//www.w3schools.com/xml/tryit.asp?filenamec
    d_catalog_island

14
Real World Applications
  • RSS (Really Simple Syndication)
  • AJAX

15
RSS(Really Simple Syndication)
  • Distributable whats new for your site
  • Mini database of headlines and descriptions
  • Use XML to build a channel or feed
  • Standardized links define RSS
  • Contains static site info and dynamic info about
    news stories
  • File must be validated

16
RSS
  • Syndication
  • Make list of links and/or content available on
    your site
  • Make sure people know (use a link)
  • Target to other web sites, news readers, e-mail,
    PDAs, cell phones, voice updates, etc.
  • RSS Aggregators
  • Most common use of RSS feeds
  • Automatically gather RSS files from content
    providers and present them in a single place in a
    variety of formats
  • Web portals (e.g., My Yahoo)
  • E-mail clients (e.g., FeedBlitz)
  • Standalone software (e.g., various newsreaders)

17
RSS
  • Why make feeds available?
  • Allow visitors to see whats new at your site
    without actually visiting
  • Encourages more traffic
  • Creating a feed
  • Dont want to do manually!
  • Many tools exist
  • PHP includes an RSS library for generating feeds
Write a Comment
User Comments (0)
About PowerShow.com