SlideShare a Scribd company logo
1 of 13
Download to read offline
XML
Características
•Transmite contenido y estructura.
•No transmite presentación ni comportamiento. Para que lo haga
se le debe asociar mecanismos adicionales.
•XML para la comunicación entre aplicaciones: representación de
los datos muy simple, fácil de transmitir por la red, estándar. En
los últimos tiempos este uso se está haciendo muy popular con el
surgimiento de los Servicios web.




                                                                     1
•Que fuera idéntico a la hora de servir, recibir, y procesar la
información del HTML para aprovechar toda la tecnología implantada
de este.
•Que fuera normal y conciso desde el punto de vista de los datos y la
manera de guardarlos.
•Que fuera extensible, para que lo puedan utilizar en todos los
campos del conocimiento.
•Que fuese fácil de leer y editar.
•Que fuese fácil de implantar, programar y aplicar a los distintos
sistemas




                                                                    2
Example: A Simple XML Page
<?xml version="1.0"?>
<employees>
  <employee>
    <employee_id>120</employee_id>
    <last_name>Weiss</last_name>
    <salary>8000</salary>
  </employee>
  <employee>
    <employee_id>121</employee_id>
    <last_name>Fripp</last_name>
    <salary>8200</salary>
  </employee>
</employees>
                                     3
XML Document Structure
• An XML document contains the following
  parts:
  1. Prologue
  2. Root element
  3. Epilogue
   <?xml version="1.0" encoding="WINDOWS-1252"?>   1
   <!–- this is a comment -->
   <employees>
    ...                                            2
   </employees>

   <?gifPlayer size="100,300" ?>                   3
                                                       4
The XML Declaration
• XML documents must start with an XML
  declaration.
• The XML declaration:
  – <?xml version="1.0" encoding="WINDOWS-1252"?> xml
    Looks like a processing instruction with the
    <document-root>
    name. For example:
    ...
   </document-root>

  – Must contain the version attribute
  – May (optionally) include:
     • The encoding attribute
     • The standalone attribute
  – Is optional in XML 1.0, but mandatory in XML 1.1    5
Components of an XML Document
• XML documents comprise storage units
  containing:
  – Parsed data, including the:
     • Markup (elements, attributes, entities) used to describe
       the data they contain
     • Character data described by markup
   <?xml version="1.0" encoding="WINDOWS-1252"?>
   <employees>
     <employee id="100">
       <name>Rachael O&apos;Leary</name>
     </employee>
   </employees>
    <![CDATA[   ...unparsed data... ]]>
  – Unparsed data, textual or binary information
    (graphic and sound data) taken as entered                     6
XML Elements
– An XML element:
  • Has a start tag, end tag, and optional data content
  • Tag names are case-sensitive (must be identical)

                                    Tag name
                  <employee>          Start tag
                                                  Data
   Element         <name>Steven King</name>
                                                  content
                  </employee>         End tag
                                     Tag name


– Empty elements:
  • Do not contain any data         <initials></initials>
  • May appear as a single tag                              7
XML Attributes
• An XML attribute is a name-value pair that:
  – Is specified in the start tag, after the tag name
   <?xml version="1.0" encoding="WINDOWS-1252"?>
   <employees>
     <employee id="100" name='Rachael O&apos;Leary'>
       <salary>1000</salary>
     </employee>
   </employees>

  – Has a case-sensitive name
  – Has a case-sensitive value that must be enclosed in
    matching single or double quotes
  – Provides additional information about the XML
    document or XML elements                            8
Using Elements Versus Attributes
 <?xml version="1.0"?>
 <employees>                             1 Elements
   <employee>
     <id>100</id>
     <last_name>King</last_name>
     <salary>24000</salary>
   </employee>
 </employees>

 <?xml version="1.0"?>
 <employees>                             2   Attributes
   <employee id="100" last_name="King"
              salary="24000">
     <job>President</job>
   </employee>
 </employees>


                                                          9
XML Entities
• An XML entity:
  – Is a unit of data storage
  – Is identified by a case-sensitive name
  – Is used as replacement text (substituted) when
    referencing its name between an ampersand (&),
    and a semicolon (;)
    <comment>Salaries must not be &lt; 1000</comment>

  – Has predefined names for special XML characters:
     •   &lt; for less than (<), and &gt; for greater than (>)
     •   &amp; for ampersand (&)
     •   &quot; for double quote (")
     •   &apos; for single quote (')                             10
XML Comments
• XML comments:
  – Start with <!--
  – End with -->
  – May appear anywhere in the character data of a
    document, and before the root element
  – Are not elements, and can occupy multiple lines
  – May not appear inside a tag or another
    comment
  <?xml version="1.0" encoding="WINDOWS-1252"?>
  <!–- Comment: This document has information about
       employees in the company -->
  <employees>
   <name>Steven King</name> <!-- Full name -->
  </employees>
                                                      11
Class Activity
• Identify errors in the following examples:
<?xml version="1.0"?>
<Question>Is this legal?</Question>               1
<Answer>No</Answer>

<!-- An XML document -->
<?xml version="1.0"?>                             2


<Question 4You="Is this attribute name correct"/> 3


<EMAIL ID=Mark.Ant@oracle.com></EMAIL>            4

<Question>Is this legal</question>                5

                                                      12
Class Activity

      1. Both <Question> and <Answer> are top-level elements. You
      can have only one document element per document.
      2. In general, you cannot have a comment before the
      XML declaration, and the root element is required.
      Note: Internet Explorer allows a comment before the
      XML declaration.
      3. The attribute name cannot start with a digit.
      4. The attribute value is not enclosed in quotes.
      5. Opening and closing tag names are case-sensitive
      and must match.




                                                             13

More Related Content

What's hot

Sql Pass Through
Sql Pass ThroughSql Pass Through
Sql Pass Through
jrhampt
 

What's hot (20)

02 well formed and valid documents
02 well formed and valid documents02 well formed and valid documents
02 well formed and valid documents
 
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDSORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
ORACLE PL/SQL TUTORIALS - OVERVIEW - SQL COMMANDS
 
XML
XMLXML
XML
 
Basics and different xml files used in android
Basics and different xml files used in androidBasics and different xml files used in android
Basics and different xml files used in android
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
 
Lesson01 学会使用基本的SQL语句
Lesson01 学会使用基本的SQL语句Lesson01 学会使用基本的SQL语句
Lesson01 学会使用基本的SQL语句
 
Oracle SQL Basics
Oracle SQL BasicsOracle SQL Basics
Oracle SQL Basics
 
XML - The Extensible Markup Language
XML - The Extensible Markup LanguageXML - The Extensible Markup Language
XML - The Extensible Markup Language
 
XML
XMLXML
XML
 
Eo gaddis java_chapter_16_5e
Eo gaddis java_chapter_16_5eEo gaddis java_chapter_16_5e
Eo gaddis java_chapter_16_5e
 
Analytical Functions for DWH
Analytical Functions for DWHAnalytical Functions for DWH
Analytical Functions for DWH
 
XML DTD Validate
XML DTD ValidateXML DTD Validate
XML DTD Validate
 
PostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | EdurekaPostgreSQL Tutorial For Beginners | Edureka
PostgreSQL Tutorial For Beginners | Edureka
 
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
SQL202.1 Accelerated Introduction to SQL Using SQL Server Module 1
 
Introduction to Oracle
Introduction to OracleIntroduction to Oracle
Introduction to Oracle
 
Xml andweb services
Xml andweb services Xml andweb services
Xml andweb services
 
Intro
IntroIntro
Intro
 
Oracle SQL Part 2
Oracle SQL Part 2Oracle SQL Part 2
Oracle SQL Part 2
 
SQL Differences SQL Interview Questions
SQL Differences  SQL Interview QuestionsSQL Differences  SQL Interview Questions
SQL Differences SQL Interview Questions
 
Sql Pass Through
Sql Pass ThroughSql Pass Through
Sql Pass Through
 

Viewers also liked

BDJ Team_Oct2015_pg_BADT
BDJ Team_Oct2015_pg_BADTBDJ Team_Oct2015_pg_BADT
BDJ Team_Oct2015_pg_BADT
Julie Bissett
 

Viewers also liked (20)

Android de la A a la Z Actividades ulises gonzalez
Android de la A a la Z   Actividades ulises gonzalezAndroid de la A a la Z   Actividades ulises gonzalez
Android de la A a la Z Actividades ulises gonzalez
 
Todo trabajo es temporal
Todo trabajo es temporalTodo trabajo es temporal
Todo trabajo es temporal
 
Bloguian
BloguianBloguian
Bloguian
 
Android service
Android serviceAndroid service
Android service
 
Curso Taller Android Procesado Imagen
Curso Taller Android Procesado ImagenCurso Taller Android Procesado Imagen
Curso Taller Android Procesado Imagen
 
operaciones aritméticas usando
operaciones aritméticas  usando operaciones aritméticas  usando
operaciones aritméticas usando
 
Servicio de desarrollo de Apps para iPhone, Android y Kindle ofrecido por App...
Servicio de desarrollo de Apps para iPhone, Android y Kindle ofrecido por App...Servicio de desarrollo de Apps para iPhone, Android y Kindle ofrecido por App...
Servicio de desarrollo de Apps para iPhone, Android y Kindle ofrecido por App...
 
Android: Interfaz de Usuario
Android: Interfaz de UsuarioAndroid: Interfaz de Usuario
Android: Interfaz de Usuario
 
ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2
ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2
ESTRUCTURA DE UN PROYECTO EN ANDROID STUDIO 2.2
 
Desarrollo android - 6 - multimedia
Desarrollo android - 6 - multimediaDesarrollo android - 6 - multimedia
Desarrollo android - 6 - multimedia
 
Hola mundo
Hola mundoHola mundo
Hola mundo
 
Intro. a Android Instituto Bosc de la Coma en Olot
Intro. a Android Instituto Bosc de la Coma en OlotIntro. a Android Instituto Bosc de la Coma en Olot
Intro. a Android Instituto Bosc de la Coma en Olot
 
BDJ Team_Oct2015_pg_BADT
BDJ Team_Oct2015_pg_BADTBDJ Team_Oct2015_pg_BADT
BDJ Team_Oct2015_pg_BADT
 
Er. Anand Resume
Er. Anand ResumeEr. Anand Resume
Er. Anand Resume
 
Interfaces increibles en Android
Interfaces increibles en AndroidInterfaces increibles en Android
Interfaces increibles en Android
 
Desarrollo en Android: Conceptos Básicos
Desarrollo en Android: Conceptos BásicosDesarrollo en Android: Conceptos Básicos
Desarrollo en Android: Conceptos Básicos
 
Game store app(2)
Game store app(2)Game store app(2)
Game store app(2)
 
Sincronización de BD SQLite con MySQL en Android
Sincronización de BD SQLite con MySQL en AndroidSincronización de BD SQLite con MySQL en Android
Sincronización de BD SQLite con MySQL en Android
 
Education and Management of Diabetics
Education and Management of DiabeticsEducation and Management of Diabetics
Education and Management of Diabetics
 
Iniciación a Android
Iniciación a AndroidIniciación a Android
Iniciación a Android
 

Similar to Android de la A a la Z XML Ulises Gonzalez

XML Presentation-2
XML Presentation-2XML Presentation-2
XML Presentation-2
Sudharsan S
 

Similar to Android de la A a la Z XML Ulises Gonzalez (20)

Unit3wt
Unit3wtUnit3wt
Unit3wt
 
XML notes.pptx
XML notes.pptxXML notes.pptx
XML notes.pptx
 
Xmll
XmllXmll
Xmll
 
1 xml fundamentals
1 xml fundamentals1 xml fundamentals
1 xml fundamentals
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5   XMLM.FLORENCE DAYANA WEB DESIGN -Unit 5   XML
M.FLORENCE DAYANA WEB DESIGN -Unit 5 XML
 
PHP XML
PHP XMLPHP XML
PHP XML
 
eXtensible Markup Language (By Dr.Hatem Mohamed)
eXtensible Markup Language (By Dr.Hatem Mohamed)eXtensible Markup Language (By Dr.Hatem Mohamed)
eXtensible Markup Language (By Dr.Hatem Mohamed)
 
XML.pptx
XML.pptxXML.pptx
XML.pptx
 
xml introduction in web technologies subject
xml introduction in web technologies subjectxml introduction in web technologies subject
xml introduction in web technologies subject
 
Xml
XmlXml
Xml
 
XML, DTD & XSD Overview
XML, DTD & XSD OverviewXML, DTD & XSD Overview
XML, DTD & XSD Overview
 
Unit 5 xml (1)
Unit 5   xml (1)Unit 5   xml (1)
Unit 5 xml (1)
 
Xml
XmlXml
Xml
 
Xml 1
Xml 1Xml 1
Xml 1
 
Xsd
XsdXsd
Xsd
 
Xsd
XsdXsd
Xsd
 
XML Presentation-2
XML Presentation-2XML Presentation-2
XML Presentation-2
 
XML
XMLXML
XML
 
Ch2 neworder
Ch2 neworderCh2 neworder
Ch2 neworder
 

More from Android UNAM

More from Android UNAM (17)

Móviles, fuerza de cambio
Móviles, fuerza de cambioMóviles, fuerza de cambio
Móviles, fuerza de cambio
 
Android de la A a la Z PARTE 3 de 3 ulises gonzalez
Android de la A a la Z  PARTE 3 de 3 ulises gonzalezAndroid de la A a la Z  PARTE 3 de 3 ulises gonzalez
Android de la A a la Z PARTE 3 de 3 ulises gonzalez
 
Android de la A a la z componentes de una aplicacion ulises gonzalez
Android de la A a la z   componentes de una aplicacion ulises gonzalezAndroid de la A a la z   componentes de una aplicacion ulises gonzalez
Android de la A a la z componentes de una aplicacion ulises gonzalez
 
Android de la A a la Z PARTE 2 de 3 ulises gonzalez
Android de la A a la Z  PARTE 2 de 3 ulises gonzalezAndroid de la A a la Z  PARTE 2 de 3 ulises gonzalez
Android de la A a la Z PARTE 2 de 3 ulises gonzalez
 
Android de la A a la Z PARTE 1 de 3 ulises gonzalez
Android de la A a la Z PARTE 1 de 3 ulises gonzalezAndroid de la A a la Z PARTE 1 de 3 ulises gonzalez
Android de la A a la Z PARTE 1 de 3 ulises gonzalez
 
"Android de la A a la Z" -- Unidad 11
"Android de la A a la Z" -- Unidad 11"Android de la A a la Z" -- Unidad 11
"Android de la A a la Z" -- Unidad 11
 
"Android de la A a la Z" -- Unidad 10
"Android de la A a la Z" -- Unidad 10"Android de la A a la Z" -- Unidad 10
"Android de la A a la Z" -- Unidad 10
 
"Android de la A a la Z" -- Unidad 4
"Android de la A a la Z" -- Unidad 4"Android de la A a la Z" -- Unidad 4
"Android de la A a la Z" -- Unidad 4
 
"Android de la A a la Z" -- Unidad 9
"Android de la A a la Z" -- Unidad 9"Android de la A a la Z" -- Unidad 9
"Android de la A a la Z" -- Unidad 9
 
"Android de la A a la Z" -- Unidad 8
"Android de la A a la Z" -- Unidad 8"Android de la A a la Z" -- Unidad 8
"Android de la A a la Z" -- Unidad 8
 
Android de la A a la Z" -- Unidad 7
Android de la A a la Z" -- Unidad 7Android de la A a la Z" -- Unidad 7
Android de la A a la Z" -- Unidad 7
 
"Android de la A a la Z" -- Unidad 6
"Android de la A a la Z" -- Unidad 6"Android de la A a la Z" -- Unidad 6
"Android de la A a la Z" -- Unidad 6
 
"Android de la A a la Z" -- Unidad 5
"Android de la A a la Z" -- Unidad 5"Android de la A a la Z" -- Unidad 5
"Android de la A a la Z" -- Unidad 5
 
"Android de la A a la Z" -- Unidad 3
"Android de la A a la Z" -- Unidad 3"Android de la A a la Z" -- Unidad 3
"Android de la A a la Z" -- Unidad 3
 
"Android de la A a la Z" -- Unidad 2
"Android de la A a la Z" -- Unidad 2"Android de la A a la Z" -- Unidad 2
"Android de la A a la Z" -- Unidad 2
 
"Android de la A a la Z" -- Unidad 1
"Android de la A a la Z" -- Unidad 1"Android de la A a la Z" -- Unidad 1
"Android de la A a la Z" -- Unidad 1
 
"Android de la A a la Z" -- Introducción
"Android de la A a la Z" -- Introducción"Android de la A a la Z" -- Introducción
"Android de la A a la Z" -- Introducción
 

Recently uploaded

Recently uploaded (20)

MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...Workshop - Best of Both Worlds_ Combine  KG and Vector search for  enhanced R...
Workshop - Best of Both Worlds_ Combine KG and Vector search for enhanced R...
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Scaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organizationScaling API-first – The story of a global engineering organization
Scaling API-first – The story of a global engineering organization
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
GenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdfGenAI Risks & Security Meetup 01052024.pdf
GenAI Risks & Security Meetup 01052024.pdf
 
Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024Partners Life - Insurer Innovation Award 2024
Partners Life - Insurer Innovation Award 2024
 
Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024Top 10 Most Downloaded Games on Play Store in 2024
Top 10 Most Downloaded Games on Play Store in 2024
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdfUnderstanding Discord NSFW Servers A Guide for Responsible Users.pdf
Understanding Discord NSFW Servers A Guide for Responsible Users.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024Manulife - Insurer Innovation Award 2024
Manulife - Insurer Innovation Award 2024
 
HTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation StrategiesHTML Injection Attacks: Impact and Mitigation Strategies
HTML Injection Attacks: Impact and Mitigation Strategies
 

Android de la A a la Z XML Ulises Gonzalez

  • 1. XML Características •Transmite contenido y estructura. •No transmite presentación ni comportamiento. Para que lo haga se le debe asociar mecanismos adicionales. •XML para la comunicación entre aplicaciones: representación de los datos muy simple, fácil de transmitir por la red, estándar. En los últimos tiempos este uso se está haciendo muy popular con el surgimiento de los Servicios web. 1
  • 2. •Que fuera idéntico a la hora de servir, recibir, y procesar la información del HTML para aprovechar toda la tecnología implantada de este. •Que fuera normal y conciso desde el punto de vista de los datos y la manera de guardarlos. •Que fuera extensible, para que lo puedan utilizar en todos los campos del conocimiento. •Que fuese fácil de leer y editar. •Que fuese fácil de implantar, programar y aplicar a los distintos sistemas 2
  • 3. Example: A Simple XML Page <?xml version="1.0"?> <employees> <employee> <employee_id>120</employee_id> <last_name>Weiss</last_name> <salary>8000</salary> </employee> <employee> <employee_id>121</employee_id> <last_name>Fripp</last_name> <salary>8200</salary> </employee> </employees> 3
  • 4. XML Document Structure • An XML document contains the following parts: 1. Prologue 2. Root element 3. Epilogue <?xml version="1.0" encoding="WINDOWS-1252"?> 1 <!–- this is a comment --> <employees> ... 2 </employees> <?gifPlayer size="100,300" ?> 3 4
  • 5. The XML Declaration • XML documents must start with an XML declaration. • The XML declaration: – <?xml version="1.0" encoding="WINDOWS-1252"?> xml Looks like a processing instruction with the <document-root> name. For example: ... </document-root> – Must contain the version attribute – May (optionally) include: • The encoding attribute • The standalone attribute – Is optional in XML 1.0, but mandatory in XML 1.1 5
  • 6. Components of an XML Document • XML documents comprise storage units containing: – Parsed data, including the: • Markup (elements, attributes, entities) used to describe the data they contain • Character data described by markup <?xml version="1.0" encoding="WINDOWS-1252"?> <employees> <employee id="100"> <name>Rachael O&apos;Leary</name> </employee> </employees> <![CDATA[ ...unparsed data... ]]> – Unparsed data, textual or binary information (graphic and sound data) taken as entered 6
  • 7. XML Elements – An XML element: • Has a start tag, end tag, and optional data content • Tag names are case-sensitive (must be identical) Tag name <employee> Start tag Data Element <name>Steven King</name> content </employee> End tag Tag name – Empty elements: • Do not contain any data <initials></initials> • May appear as a single tag 7
  • 8. XML Attributes • An XML attribute is a name-value pair that: – Is specified in the start tag, after the tag name <?xml version="1.0" encoding="WINDOWS-1252"?> <employees> <employee id="100" name='Rachael O&apos;Leary'> <salary>1000</salary> </employee> </employees> – Has a case-sensitive name – Has a case-sensitive value that must be enclosed in matching single or double quotes – Provides additional information about the XML document or XML elements 8
  • 9. Using Elements Versus Attributes <?xml version="1.0"?> <employees> 1 Elements <employee> <id>100</id> <last_name>King</last_name> <salary>24000</salary> </employee> </employees> <?xml version="1.0"?> <employees> 2 Attributes <employee id="100" last_name="King" salary="24000"> <job>President</job> </employee> </employees> 9
  • 10. XML Entities • An XML entity: – Is a unit of data storage – Is identified by a case-sensitive name – Is used as replacement text (substituted) when referencing its name between an ampersand (&), and a semicolon (;) <comment>Salaries must not be &lt; 1000</comment> – Has predefined names for special XML characters: • &lt; for less than (<), and &gt; for greater than (>) • &amp; for ampersand (&) • &quot; for double quote (") • &apos; for single quote (') 10
  • 11. XML Comments • XML comments: – Start with <!-- – End with --> – May appear anywhere in the character data of a document, and before the root element – Are not elements, and can occupy multiple lines – May not appear inside a tag or another comment <?xml version="1.0" encoding="WINDOWS-1252"?> <!–- Comment: This document has information about employees in the company --> <employees> <name>Steven King</name> <!-- Full name --> </employees> 11
  • 12. Class Activity • Identify errors in the following examples: <?xml version="1.0"?> <Question>Is this legal?</Question> 1 <Answer>No</Answer> <!-- An XML document --> <?xml version="1.0"?> 2 <Question 4You="Is this attribute name correct"/> 3 <EMAIL ID=Mark.Ant@oracle.com></EMAIL> 4 <Question>Is this legal</question> 5 12
  • 13. Class Activity 1. Both <Question> and <Answer> are top-level elements. You can have only one document element per document. 2. In general, you cannot have a comment before the XML declaration, and the root element is required. Note: Internet Explorer allows a comment before the XML declaration. 3. The attribute name cannot start with a digit. 4. The attribute value is not enclosed in quotes. 5. Opening and closing tag names are case-sensitive and must match. 13