ºÝºÝߣ

ºÝºÝߣShare a Scribd company logo
XML
IntroductionWhat is XML?The Difference Between XML and HTML
How to useXML Separates Data from HTMLXML Simplifies Data SharingXML Simplifies Data TransportXML Simplifies Platform ChangesXML is Used to Create New Internet Languages
XML TreeAn Example XML Document<?xml version="1.0" encoding="ISO-8859-1"?><note>Ìý <to>Tove</to>Ìý <from>Jani</from>Ìý <heading>Reminder</heading>Ìý <body>Don't forget me this weekend!</body></note>
XML Tree cont..	XML Documents Form a Tree Structure<bookstore>Ìý <book category="COOKING">ÌýÌýÌý <title lang="en">Everyday Italian</title>ÌýÌýÌý <author>Giada De Laurentiis</author>ÌýÌýÌý <year>2005</year>ÌýÌýÌý <price>30.00</price>Ìý </book>
XML Syntax RulesAll XML Elements Must Have a Closing Tag<p>This is another paragraph</p>XML Tags are Case Sensitive<Message>This is incorrect</message><message>This is correct</message>XML Elements Must be Properly Nested<b><i>This text is bold and italic</b></i><b><i>This text is bold and italic</i></b>
XML Syntax Rules cont..XML Documents Must Have a Root Element<root>Ìý <child>ÌýÌý..... Ìý </child></root>XML Attribute Values Must be Quoted<note date="12/11/2007">…</note>Entity ReferencesThere are 5 predefined entity references in XML:&lt; 	< 	less than &gt; 	> 	greater than &amp; 	& 	ampersand  &apos; 	' 	apostrophe &quot; 	" 	quotation mark <message>if salary &lt; 1000 then</message>
XML Syntax Rules cont…Comments in XML<!-- This is a comment --> White-space is Preserved in XMLHTML truncates multiple white-space characters to one single white-space:HTML:  Hello           ToveOutput:  Hello ToveWith XML, the white-space in a document is not truncated.XML Stores New Line as LF‘\n’New line – Line feedCR – Carriage Return ‘\r’LF – Line Feed ‘\n’
XML ElementsWhat is an XML Element?<bookstore>Ìý <book category="CHILDREN">ÌýÌýÌý <title>Harry Potter</title>ÌýÌýÌý <author>J K. Rowling</author>ÌýÌýÌý <year>2005</year>ÌýÌýÌý <price>29.99</price>Ìý </book>Ìý <book category="WEB">ÌýÌýÌý <title>Learning XML</title>ÌýÌýÌý <author>Erik T. Ray</author>ÌýÌýÌý <year>2003</year>ÌýÌýÌý <price>39.95</price>Ìý </book></bookstore>
XML Elements cont…XML Naming RulesNames can contain letters, numbers, and other characters
Names cannot start with a number or punctuation character
Names cannot start with the letters xml (or XML, or Xml, etc)
Names cannot contain spacesBest Naming PracticesMake names descriptive. Names with an underscore separator are nice: <first_name>, <last_name>.
Names should be short and simple, like this: <book_title> not like this: <the_title_of_the_book>.
Avoid "-" characters. If you name something "first-name," some software may think you want to subtract name from first.
Avoid "." characters. If you name something "first.name," some software may think that "name" is a property of the object "first."
Avoid ":" characters. Colons are reserved to be used for something called namespaces (more later).
Non-English letters like éòá are perfectly legal in XML, but watch out for problems if your software vendor doesn't support them.XML Attributes<file type="gif">computer.gif</file>XML Attributes Must be Quoted<person sex="female"> or <person sex='female'>XML Elements vs. Attributes<person gender="female">Ìý <firstname>Anna</firstname>Ìý <lastname>Smith</lastname></person><person>Ìý <gender >female</gender >Ìý <firstname>Anna</firstname>Ìý <lastname>Smith</lastname></person>

More Related Content

What's hot (20)

XML
XMLXML
XML
Mukesh Tekwani
Ìý
Xml
XmlXml
Xml
Venkat Krishnan
Ìý
Lecture 5 XML
Lecture 5  XMLLecture 5  XML
Lecture 5 XML
Sur College of Applied Sciences
Ìý
XML
XMLXML
XML
Mukesh Tekwani
Ìý
Basic html
Basic htmlBasic html
Basic html
Drew Eric Noftle
Ìý
XML Introduction
XML IntroductionXML Introduction
XML Introduction
Marco Bresciani
Ìý
Html guide
Html guideHtml guide
Html guide
Dileysi
Ìý
Html1
Html1Html1
Html1
Emily McWorthy
Ìý
Xml
XmlXml
Xml
guestcacd813
Ìý
INTRODUCTION TO HTML
INTRODUCTION TO HTMLINTRODUCTION TO HTML
INTRODUCTION TO HTML
bwire sedrick
Ìý
About XML
About XMLAbout XML
About XML
David Rajah Selvaraj
Ìý
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
BG Java EE Course
Ìý
Xml description
Xml descriptionXml description
Xml description
sonam gupta
Ìý
Class2
Class2Class2
Class2
Jiyeon Lee
Ìý
The Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for BeginnersThe Difference between HTML, XHTML & HTML5 for Beginners
The Difference between HTML, XHTML & HTML5 for Beginners
Rasin Bekkevold
Ìý
Lecture 2 introduction to html
Lecture 2  introduction to htmlLecture 2  introduction to html
Lecture 2 introduction to html
palhaftab
Ìý
Xhtml
XhtmlXhtml
Xhtml
Manav Prasad
Ìý
Xhtml
XhtmlXhtml
Xhtml
Samir Sabry
Ìý
Sgml
SgmlSgml
Sgml
rahul kundu
Ìý
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
vikasgaur31
Ìý

Viewers also liked (7)

business telephone systems
business telephone systemsbusiness telephone systems
business telephone systems
joe
Ìý
Estudios Estudios
Estudios
MariCc2
Ìý
100818 chia khoa niem vui
100818 chia khoa niem vui100818 chia khoa niem vui
100818 chia khoa niem vui
Tran Tuan
Ìý
HTML and XML Difference FAQs
HTML and XML Difference FAQsHTML and XML Difference FAQs
HTML and XML Difference FAQs
Umar Ali
Ìý
Hanh trinh-tro-thanh-nha-lanh-dao
Hanh trinh-tro-thanh-nha-lanh-daoHanh trinh-tro-thanh-nha-lanh-dao
Hanh trinh-tro-thanh-nha-lanh-dao
Xuan Le
Ìý
JSON API_1110651039
JSON API_1110651039JSON API_1110651039
JSON API_1110651039
gagahprawono
Ìý
Destaques Projeto SubaDestaques Projeto Suba
Destaques Projeto Suba
JErickPPTs
Ìý
business telephone systems
business telephone systemsbusiness telephone systems
business telephone systems
joe
Ìý
Estudios Estudios
Estudios
MariCc2
Ìý
100818 chia khoa niem vui
100818 chia khoa niem vui100818 chia khoa niem vui
100818 chia khoa niem vui
Tran Tuan
Ìý
HTML and XML Difference FAQs
HTML and XML Difference FAQsHTML and XML Difference FAQs
HTML and XML Difference FAQs
Umar Ali
Ìý
Hanh trinh-tro-thanh-nha-lanh-dao
Hanh trinh-tro-thanh-nha-lanh-daoHanh trinh-tro-thanh-nha-lanh-dao
Hanh trinh-tro-thanh-nha-lanh-dao
Xuan Le
Ìý
JSON API_1110651039
JSON API_1110651039JSON API_1110651039
JSON API_1110651039
gagahprawono
Ìý
Destaques Projeto SubaDestaques Projeto Suba
Destaques Projeto Suba
JErickPPTs
Ìý

Similar to Xml (20)

Xmlphp
XmlphpXmlphp
Xmlphp
kiran vadariya
Ìý
Xml
XmlXml
Xml
Kunal Gaind
Ìý
Xml
XmlXml
Xml
Vishwa Mohan
Ìý
Lotusphere 2006 AD212 Introduction to DXL
Lotusphere 2006 AD212 Introduction to DXLLotusphere 2006 AD212 Introduction to DXL
Lotusphere 2006 AD212 Introduction to DXL
dominion
Ìý
XML and XSLT
XML and XSLTXML and XSLT
XML and XSLT
Andrew Savory
Ìý
Xml Demystified
Xml DemystifiedXml Demystified
Xml Demystified
Viraf Karai
Ìý
Mdst 3559-02-01-html
Mdst 3559-02-01-htmlMdst 3559-02-01-html
Mdst 3559-02-01-html
Rafael Alvarado
Ìý
3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schema
gauravashq
Ìý
What is xml
What is xmlWhat is xml
What is xml
Sachit Singh
Ìý
XML processing with perl
XML processing with perlXML processing with perl
XML processing with perl
Joe Jiang
Ìý
Everything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To AskEverything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To Ask
Richard Davis
Ìý
Xml Schema
Xml SchemaXml Schema
Xml Schema
vikram singh
Ìý
XML Training Presentation
XML Training PresentationXML Training Presentation
XML Training Presentation
Sarah Corney
Ìý
Xml intro1
Xml intro1Xml intro1
Xml intro1
Alfonso Gabriel López Ceballos
Ìý
Web Technology XML Attributes and elementsUnit 3.doc
Web Technology XML Attributes and elementsUnit 3.docWeb Technology XML Attributes and elementsUnit 3.doc
Web Technology XML Attributes and elementsUnit 3.doc
uthayashangar1
Ìý
Introduction To Xml
Introduction To XmlIntroduction To Xml
Introduction To Xml
bdebruin
Ìý
Pmm05 16
Pmm05 16Pmm05 16
Pmm05 16
Rohit Luthra
Ìý
Basic XML
Basic XMLBasic XML
Basic XML
Hoang Nguyen
Ìý
Xml 150323102007-conversion-gate01
Xml 150323102007-conversion-gate01Xml 150323102007-conversion-gate01
Xml 150323102007-conversion-gate01
Niraj Bharambe
Ìý
1.1 xhtml basics
1.1 xhtml basics1.1 xhtml basics
1.1 xhtml basics
Bulldogs83
Ìý
Lotusphere 2006 AD212 Introduction to DXL
Lotusphere 2006 AD212 Introduction to DXLLotusphere 2006 AD212 Introduction to DXL
Lotusphere 2006 AD212 Introduction to DXL
dominion
Ìý
Xml Demystified
Xml DemystifiedXml Demystified
Xml Demystified
Viraf Karai
Ìý
Mdst 3559-02-01-html
Mdst 3559-02-01-htmlMdst 3559-02-01-html
Mdst 3559-02-01-html
Rafael Alvarado
Ìý
3 xml namespaces and xml schema
3   xml namespaces and xml schema3   xml namespaces and xml schema
3 xml namespaces and xml schema
gauravashq
Ìý
XML processing with perl
XML processing with perlXML processing with perl
XML processing with perl
Joe Jiang
Ìý
Everything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To AskEverything You Always Wanted To Know About XML But Were Afraid To Ask
Everything You Always Wanted To Know About XML But Were Afraid To Ask
Richard Davis
Ìý
XML Training Presentation
XML Training PresentationXML Training Presentation
XML Training Presentation
Sarah Corney
Ìý
Web Technology XML Attributes and elementsUnit 3.doc
Web Technology XML Attributes and elementsUnit 3.docWeb Technology XML Attributes and elementsUnit 3.doc
Web Technology XML Attributes and elementsUnit 3.doc
uthayashangar1
Ìý
Introduction To Xml
Introduction To XmlIntroduction To Xml
Introduction To Xml
bdebruin
Ìý
Xml 150323102007-conversion-gate01
Xml 150323102007-conversion-gate01Xml 150323102007-conversion-gate01
Xml 150323102007-conversion-gate01
Niraj Bharambe
Ìý
1.1 xhtml basics
1.1 xhtml basics1.1 xhtml basics
1.1 xhtml basics
Bulldogs83
Ìý

Recently uploaded (20)

Essentials of a Good PMO, presented by Aalok Sonawala
Essentials of a Good PMO, presented by Aalok SonawalaEssentials of a Good PMO, presented by Aalok Sonawala
Essentials of a Good PMO, presented by Aalok Sonawala
Association for Project Management
Ìý
N.C. DPI's 2023 Language Diversity Briefing
N.C. DPI's 2023 Language Diversity BriefingN.C. DPI's 2023 Language Diversity Briefing
N.C. DPI's 2023 Language Diversity Briefing
Mebane Rash
Ìý
Database population in Odoo 18 - Odoo slides
Database population in Odoo 18 - Odoo slidesDatabase population in Odoo 18 - Odoo slides
Database population in Odoo 18 - Odoo slides
Celine George
Ìý
How to Manage Putaway Rule in Odoo 17 Inventory
How to Manage Putaway Rule in Odoo 17 InventoryHow to Manage Putaway Rule in Odoo 17 Inventory
How to Manage Putaway Rule in Odoo 17 Inventory
Celine George
Ìý
cervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdfcervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdf
SamarHosni3
Ìý
Reordering Rules in Odoo 17 Inventory - Odoo ºÝºÝߣs
Reordering Rules in Odoo 17 Inventory - Odoo ºÝºÝߣsReordering Rules in Odoo 17 Inventory - Odoo ºÝºÝߣs
Reordering Rules in Odoo 17 Inventory - Odoo ºÝºÝߣs
Celine George
Ìý
Mate, a short story by Kate Grenvile.pptx
Mate, a short story by Kate Grenvile.pptxMate, a short story by Kate Grenvile.pptx
Mate, a short story by Kate Grenvile.pptx
Liny Jenifer
Ìý
Modeling-Simple-Equation-Using-Bar-Models.pptx
Modeling-Simple-Equation-Using-Bar-Models.pptxModeling-Simple-Equation-Using-Bar-Models.pptx
Modeling-Simple-Equation-Using-Bar-Models.pptx
maribethlacno2
Ìý
How to use Init Hooks in Odoo 18 - Odoo ºÝºÝߣs
How to use Init Hooks in Odoo 18 - Odoo ºÝºÝߣsHow to use Init Hooks in Odoo 18 - Odoo ºÝºÝߣs
How to use Init Hooks in Odoo 18 - Odoo ºÝºÝߣs
Celine George
Ìý
Rass MELAI : an Internet MELA Quiz Prelims - El Dorado 2025
Rass MELAI : an Internet MELA Quiz Prelims - El Dorado 2025Rass MELAI : an Internet MELA Quiz Prelims - El Dorado 2025
Rass MELAI : an Internet MELA Quiz Prelims - El Dorado 2025
Conquiztadors- the Quiz Society of Sri Venkateswara College
Ìý
Storytelling instructions...............
Storytelling instructions...............Storytelling instructions...............
Storytelling instructions...............
Alexander Benito
Ìý
PUBH1000 Module 3: Public Health Systems
PUBH1000 Module 3: Public Health SystemsPUBH1000 Module 3: Public Health Systems
PUBH1000 Module 3: Public Health Systems
Jonathan Hallett
Ìý
Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025
Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025
Rass MELAI : an Internet MELA Quiz Finals - El Dorado 2025
Conquiztadors- the Quiz Society of Sri Venkateswara College
Ìý
Year 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptxYear 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptx
mansk2
Ìý
EDL 290F Week 3 - Mountaintop Views (2025).pdf
EDL 290F Week 3  - Mountaintop Views (2025).pdfEDL 290F Week 3  - Mountaintop Views (2025).pdf
EDL 290F Week 3 - Mountaintop Views (2025).pdf
Liz Walsh-Trevino
Ìý
The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .
saanidhyapatel09
Ìý
How to Setup WhatsApp in Odoo 17 - Odoo ºÝºÝߣs
How to Setup WhatsApp in Odoo 17 - Odoo ºÝºÝߣsHow to Setup WhatsApp in Odoo 17 - Odoo ºÝºÝߣs
How to Setup WhatsApp in Odoo 17 - Odoo ºÝºÝߣs
Celine George
Ìý
English 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom ObsEnglish 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom Obs
NerissaMendez1
Ìý
Research & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptxResearch & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptx
Dr. Sarita Anand
Ìý
DUBLIN PROGRAM DUBLIN PROGRAM DUBLIN PROGRAM
DUBLIN PROGRAM DUBLIN PROGRAM DUBLIN PROGRAMDUBLIN PROGRAM DUBLIN PROGRAM DUBLIN PROGRAM
DUBLIN PROGRAM DUBLIN PROGRAM DUBLIN PROGRAM
vlckovar
Ìý
N.C. DPI's 2023 Language Diversity Briefing
N.C. DPI's 2023 Language Diversity BriefingN.C. DPI's 2023 Language Diversity Briefing
N.C. DPI's 2023 Language Diversity Briefing
Mebane Rash
Ìý
Database population in Odoo 18 - Odoo slides
Database population in Odoo 18 - Odoo slidesDatabase population in Odoo 18 - Odoo slides
Database population in Odoo 18 - Odoo slides
Celine George
Ìý
How to Manage Putaway Rule in Odoo 17 Inventory
How to Manage Putaway Rule in Odoo 17 InventoryHow to Manage Putaway Rule in Odoo 17 Inventory
How to Manage Putaway Rule in Odoo 17 Inventory
Celine George
Ìý
cervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdfcervical spine mobilization manual therapy .pdf
cervical spine mobilization manual therapy .pdf
SamarHosni3
Ìý
Reordering Rules in Odoo 17 Inventory - Odoo ºÝºÝߣs
Reordering Rules in Odoo 17 Inventory - Odoo ºÝºÝߣsReordering Rules in Odoo 17 Inventory - Odoo ºÝºÝߣs
Reordering Rules in Odoo 17 Inventory - Odoo ºÝºÝߣs
Celine George
Ìý
Mate, a short story by Kate Grenvile.pptx
Mate, a short story by Kate Grenvile.pptxMate, a short story by Kate Grenvile.pptx
Mate, a short story by Kate Grenvile.pptx
Liny Jenifer
Ìý
Modeling-Simple-Equation-Using-Bar-Models.pptx
Modeling-Simple-Equation-Using-Bar-Models.pptxModeling-Simple-Equation-Using-Bar-Models.pptx
Modeling-Simple-Equation-Using-Bar-Models.pptx
maribethlacno2
Ìý
How to use Init Hooks in Odoo 18 - Odoo ºÝºÝߣs
How to use Init Hooks in Odoo 18 - Odoo ºÝºÝߣsHow to use Init Hooks in Odoo 18 - Odoo ºÝºÝߣs
How to use Init Hooks in Odoo 18 - Odoo ºÝºÝߣs
Celine George
Ìý
Storytelling instructions...............
Storytelling instructions...............Storytelling instructions...............
Storytelling instructions...............
Alexander Benito
Ìý
PUBH1000 Module 3: Public Health Systems
PUBH1000 Module 3: Public Health SystemsPUBH1000 Module 3: Public Health Systems
PUBH1000 Module 3: Public Health Systems
Jonathan Hallett
Ìý
Year 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptxYear 10 The Senior Phase Session 3 Term 1.pptx
Year 10 The Senior Phase Session 3 Term 1.pptx
mansk2
Ìý
EDL 290F Week 3 - Mountaintop Views (2025).pdf
EDL 290F Week 3  - Mountaintop Views (2025).pdfEDL 290F Week 3  - Mountaintop Views (2025).pdf
EDL 290F Week 3 - Mountaintop Views (2025).pdf
Liz Walsh-Trevino
Ìý
The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .The Constitution, Government and Law making bodies .
The Constitution, Government and Law making bodies .
saanidhyapatel09
Ìý
How to Setup WhatsApp in Odoo 17 - Odoo ºÝºÝߣs
How to Setup WhatsApp in Odoo 17 - Odoo ºÝºÝߣsHow to Setup WhatsApp in Odoo 17 - Odoo ºÝºÝߣs
How to Setup WhatsApp in Odoo 17 - Odoo ºÝºÝߣs
Celine George
Ìý
English 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom ObsEnglish 4 Quarter 4 Week 4 Classroom Obs
English 4 Quarter 4 Week 4 Classroom Obs
NerissaMendez1
Ìý
Research & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptxResearch & Research Methods: Basic Concepts and Types.pptx
Research & Research Methods: Basic Concepts and Types.pptx
Dr. Sarita Anand
Ìý
DUBLIN PROGRAM DUBLIN PROGRAM DUBLIN PROGRAM
DUBLIN PROGRAM DUBLIN PROGRAM DUBLIN PROGRAMDUBLIN PROGRAM DUBLIN PROGRAM DUBLIN PROGRAM
DUBLIN PROGRAM DUBLIN PROGRAM DUBLIN PROGRAM
vlckovar
Ìý

Xml

  • 1. XML
  • 2. IntroductionWhat is XML?The Difference Between XML and HTML
  • 3. How to useXML Separates Data from HTMLXML Simplifies Data SharingXML Simplifies Data TransportXML Simplifies Platform ChangesXML is Used to Create New Internet Languages
  • 4. XML TreeAn Example XML Document<?xml version="1.0" encoding="ISO-8859-1"?><note>Ìý <to>Tove</to>Ìý <from>Jani</from>Ìý <heading>Reminder</heading>Ìý <body>Don't forget me this weekend!</body></note>
  • 5. XML Tree cont.. XML Documents Form a Tree Structure<bookstore>Ìý <book category="COOKING">ÌýÌýÌý <title lang="en">Everyday Italian</title>ÌýÌýÌý <author>Giada De Laurentiis</author>ÌýÌýÌý <year>2005</year>ÌýÌýÌý <price>30.00</price>Ìý </book>
  • 6. XML Syntax RulesAll XML Elements Must Have a Closing Tag<p>This is another paragraph</p>XML Tags are Case Sensitive<Message>This is incorrect</message><message>This is correct</message>XML Elements Must be Properly Nested<b><i>This text is bold and italic</b></i><b><i>This text is bold and italic</i></b>
  • 7. XML Syntax Rules cont..XML Documents Must Have a Root Element<root>Ìý <child>ÌýÌý..... Ìý </child></root>XML Attribute Values Must be Quoted<note date="12/11/2007">…</note>Entity ReferencesThere are 5 predefined entity references in XML:&lt; < less than &gt; > greater than &amp; & ampersand &apos; ' apostrophe &quot; " quotation mark <message>if salary &lt; 1000 then</message>
  • 8. XML Syntax Rules cont…Comments in XML<!-- This is a comment --> White-space is Preserved in XMLHTML truncates multiple white-space characters to one single white-space:HTML: Hello ToveOutput: Hello ToveWith XML, the white-space in a document is not truncated.XML Stores New Line as LF‘\n’New line – Line feedCR – Carriage Return ‘\r’LF – Line Feed ‘\n’
  • 9. XML ElementsWhat is an XML Element?<bookstore>Ìý <book category="CHILDREN">ÌýÌýÌý <title>Harry Potter</title>ÌýÌýÌý <author>J K. Rowling</author>ÌýÌýÌý <year>2005</year>ÌýÌýÌý <price>29.99</price>Ìý </book>Ìý <book category="WEB">ÌýÌýÌý <title>Learning XML</title>ÌýÌýÌý <author>Erik T. Ray</author>ÌýÌýÌý <year>2003</year>ÌýÌýÌý <price>39.95</price>Ìý </book></bookstore>
  • 10. XML Elements cont…XML Naming RulesNames can contain letters, numbers, and other characters
  • 11. Names cannot start with a number or punctuation character
  • 12. Names cannot start with the letters xml (or XML, or Xml, etc)
  • 13. Names cannot contain spacesBest Naming PracticesMake names descriptive. Names with an underscore separator are nice: <first_name>, <last_name>.
  • 14. Names should be short and simple, like this: <book_title> not like this: <the_title_of_the_book>.
  • 15. Avoid "-" characters. If you name something "first-name," some software may think you want to subtract name from first.
  • 16. Avoid "." characters. If you name something "first.name," some software may think that "name" is a property of the object "first."
  • 17. Avoid ":" characters. Colons are reserved to be used for something called namespaces (more later).
  • 18. Non-English letters like éòá are perfectly legal in XML, but watch out for problems if your software vendor doesn't support them.XML Attributes<file type="gif">computer.gif</file>XML Attributes Must be Quoted<person sex="female"> or <person sex='female'>XML Elements vs. Attributes<person gender="female">Ìý <firstname>Anna</firstname>Ìý <lastname>Smith</lastname></person><person>Ìý <gender >female</gender >Ìý <firstname>Anna</firstname>Ìý <lastname>Smith</lastname></person>
  • 19. XML Attributes cont…Avoid XML Attributes?Some of the problems with using attributes are:attributes cannot contain multiple values (elements can)
  • 20. attributes cannot contain tree structures (elements can)
  • 21. attributes are not easily expandable (for future changes)XML ValidationValid XML Documents<?xml version="1.0" encoding="ISO-8859-1"?><!DOCTYPE note SYSTEM "Note.dtd"><note><to>Tove</to><from>Jani</from><heading>Reminder</heading><body>Don't forget me this weekend!</body></note>
  • 22. XML Validation cont…XML DTD[<!ELEMENT note (to,from,heading,body)><!ELEMENT to (#PCDATA)><!ELEMENT from (#PCDATA)><!ELEMENT heading (#PCDATA)><!ELEMENT body (#PCDATA)>]>XML Schema<xs:element name="note"><xs:complexType>Ìý <xs:sequence>ÌýÌýÌý <xs:element name="to"Ìýtype="xs:string"/>ÌýÌýÌý <xs:element name="from"Ìýtype="xs:string"/>ÌýÌýÌý <xs:element name="heading" type="xs:string"/>ÌýÌýÌý <xs:element name="body"Ìýtype="xs:string"/>Ìý </xs:sequence></xs:complexType></xs:element>
  • 23. XML ValidatorSyntax-Check Your XMLhttp://www.w3schools.com/xml/xml_validator.aspSyntax-Check an XML Filehttp://www.w3schools.com/xml/xml_validator.aspValidate Your XML Against a DTD
  • 24. Displaying XML with CSS<?xml version="1.0" encoding="ISO-8859-1"?><?xml-stylesheet type="text/css" href="cd_catalog.css"?><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>ÌýÌýÌý <TITLE>Hide your heart</TITLE>ÌýÌýÌý <ARTIST>Bonnie Tyler</ARTIST>ÌýÌýÌý <COUNTRY>UK</COUNTRY>ÌýÌýÌý <COMPANY>CBS Records</COMPANY>ÌýÌýÌý <PRICE>9.90</PRICE>ÌýÌýÌý <YEAR>1988</YEAR>Ìý </CD>...</CATALOG>http://www.w3schools.com/xml/cd_catalog.xmlhttp://www.w3schools.com/xml/cd_catalog.txthttp://www.w3schools.com/xml/cd_catalog_with_css.xml