Introduction to XML - PowerPoint PPT Presentation

1 / 18
About This Presentation
Title:

Introduction to XML

Description:

Tags describe fixed set of elements. Covers formatting, semantics ... Hip Hop/Rap; Alternative; Blues; Country; Jazz; Rock; Latin; World. Singers. Hip Hop/Rap ... – PowerPoint PPT presentation

Number of Views:12
Avg rating:3.0/5.0
Slides: 19
Provided by: madh
Category:

less

Transcript and Presenter's Notes

Title: Introduction to XML


1
Introduction to XML
  • The eXtensible Markup Language

2
HTML Vs. XML
  • HTML is a markup language
  • Fixed set of tags
  • Tags describe fixed set of elements
  • Covers formatting, semantics and structure
  • ltbgt ltSTRONGgt ltTDgt
  • XML is a meta-markup language
  • No fixed set of tags all user defined
  • Describes structure and semantics not
    formatting
  • Formatting is done by use of style sheets
    stored in a separate file

3
XML Design Objectives
  • W3C established 10 goals for XML
  • Easily used on internet
  • Must support wide variety of applications
  • Compatible with SGML
  • Easy to write programs that process XML document
  • Minimal optional features (simplicity)
  • Easy to understand by lay people
  • XML design should prepared quickly
  • Design of XML must be precise
  • XML documents easy to create
  • Terseness not important

4
Creating an XML document The Process
Create XML document
Parse document using XML processor
Display document
5
XML First Try
  • lt?xml version1.0?gt
  • ltGREETINGgt
  • Hello, World
  • lt/GREETINGgt

6
The XML Declaration
  • lt?xml version1.0?gt
  • The tag is xml and version is the attribute
  • 1.0 is version of xml to which document conforms
  • Always start with this declaration
  • Note it is case-sensitive
  • No white spaces allowed

7
The Element
  • ltGREETINGgt
  • Hello, World
  • lt/GREETINGgt
  • Above three lines form the GREETING element
  • ltGREETINGgt - start tag
  • Hello, World element content
  • lt/GREETINGgt -end tag

8
Inserting Comments
  • lt!--This is a comment which will not be
    displayed--gt
  • ltGREETINGgt
  • Hello, World
  • lt!-- This is a test xml file --gt
  • lt/GREETINGgt

9
CDATA Sections
  • Used to display text as is without interpretation
  • lt!CDATA
  • Text to be entered
  • gt
  • may contain most markup characters (lt,gt,!, etc.)
  • May be placed anywhere in the document
  • Cannot be nested in another CDATA
  • Cannot be empty

10
Example of CDATA section
  • ltMESSAGEgt
  • lt!CDATA
  • This is a sample of how this tag others like it
    may be used
  • gt
  • ltMESSAGEgt

11
To show formatted elements
  • To have the element content show with formatting,
    must do two things
  • Create a stylesheet file
  • Specifies how to interpret tags
  • Add a processing instruction to the xml file.
  • Tells the xml file to look at the stylesheet file
    for formatting instructions

12
Adding a stylesheet
  • The interpretation of self-defined tags (like
    ltGREETINGgt) done through use of linked CSS or XSL
    file
  • Create another file named GREETING.css
  • Would be called GREETING.xsl for XSL file
  • Define the formatting for the GREETING element
  • GREETING display block font-size 16pt
    font-weight bold font-style italic color red

13
Processing Instruction
  • lt?xml-stylesheet typetext/css
    hrefgreeting.css?gt
  • Insert after the opening XML declaration
  • Can use same CSS for multiple xml files
  • Type is set to text/xml if using XSL
  • Can also be linked to a URL

14
Structuring Data in XML
  • Consider data about music
  • Genres of music
  • Hip Hop/Rap Alternative Blues Country Jazz
    Rock Latin World
  • Singers
  • Hip Hop/Rap
  • Eminem Busta Rhymes Nelly Ja Rule Missy
    Elliot
  • Album
  • Busta Rhymes
  • It Aint Safe No More
  • Song
  • It Aint Safe No More
  • Make It Clap

15
Some of the tags
  • You can make up your own names but they should
    be meaningful
  • ltMUSICgt
  • ltGENREgt
  • ltARTISTgt
  • ltALBUMgt
  • ltSONGgt

16
Root Element
  • Every good xml document has a root element
  • Root elements contain all other elements
  • In this case, the ltMUSICgt start tag is the first
    tag in the document
  • lt/MUSICgt end tag will be the last
  • Tags must be nested , never overlap

17
Nested vs Overlapping tags
  • ltCONFERENCEgt
  • ltTEAMgt
  • ltPLAYERgt
  • lt/PLAYERgt
  • lt/TEAMgt
  • lt/CONFERENCEgt

Example of NESTED TAGS
18
Nested vs Overlapping tags
  • ltCONFERENCEgt
  • ltTEAMgt
  • ltPLAYERgt
  • lt/TEAMgt
  • lt/CONFERENCEgt
  • lt/PLAYERgt

Example of OVERLAPPING TAGS
Write a Comment
User Comments (0)
About PowerShow.com