SlideShare ist ein Scribd-Unternehmen logo
1 von 25
XML
EXtensible Markup Language


Introduction
Definition
   XML stands for EXtensible Markup
    Language
   XML is a markup language much like HTML
   XML was designed to carry data, to
    transport and store data, not to display data
   XML tags are not predefined. You must
    define your own tags
   XML is designed to be self-descriptive
The best description of XML is: “XML is a
software and hardware-independent tool for
carrying information”.
XML & HTML
 XML is not a replacement for HTML.
 XML and HTML were designed with
  different goals:
    ◦ XML was designed to transport and store
      data, with focus on what data is
    ◦ HTML was designed to display data, with
      focus on how data looks
    ◦ HTML is about displaying
      information, while XML is about carrying
      information.
First Example
<note>
<to>Tove</to>
<from>Jani</from>
<heading>Reminder</heading>
<body>Don't forget me this weekend!</body>
</note>



   The note above is quite self-descriptive.
    It has sender and receiver
    information, it also has a heading and a
    message body.
XML Tags
 The tags in the example above (like <to>
  and <from>) are not defined in any XML
  standard. These tags are "invented" by the
  author of the XML document.
 That is because the XML language has no
  predefined tags.
 The tags used in HTML are predefined.
  HTML documents can only use tags defined
  in the HTML standard (like <p>, <h1>, etc.).
 XML allows the author to define his/her own
  tags and his/her own document structure.
XML Main Features
XML Simplifies Data Transport

Exchanging data as XML greatly reduces this
complexity, since the data can be read by different
incompatible applications.

                                              JAVA
   PHP


                         DOC.
                         XML




                        .NET
XML Separates Data from HTML

If you need to display dynamic data in your HTML
document, it will take a lot of work to edit the HTML each time
the data changes.

With XML, data can be stored in separate XML files. This way
you can concentrate on using HTML/CSS for display and
layout, and be sure that changes in the underlying data will
not require any changes to the HTML..
XML Makes Your Data More Available
Different applications can access your data, not only in
HTML pages, but also from XML data sources.

With XML, your data can be available to all kinds of "reading
machines" (Handheld computers, voice machines, news
feeds, etc), and make it more available for blind people, or
people with other disabilities.
XML Simplifies Platform Changes

XML data is stored in text format. This makes it
easier to expand or upgrade to new operating
systems, new applications, or new
browsers, without losing data.


XML Simplifies Data Sharing

In the real world, computer systems and
databases contain data in incompatible formats.
XML Tree
   XML documents form a tree structure that
    starts at "the root" and branches to "the
    leaves".
Tree Structure
 XML documents must contain a root element. This
  element is "the parent" of all other elements.
 The elements in an XML document form a
  document tree. The tree starts at the root and
  branches to the lowest level of the tree.
 All elements can have sub elements (child
  elements).
    <root>
     <child>
       <subchild attribute=”value”>.....</subchild>
     </child>
    </root>
XML Syntax Rules
   All XML Elements Must Have a Closing Tag.
   XML Tags are Case Sensitive.
   XML Elements Must be Properly Nested.
   XML Documents Must Have a Root Element.
   XML Attribute Values Must be Quoted.

<root>
 <child>
   <subchild attribute=”value”>value #1</subchild>
 </child>
</root>
XML Elements
   An XML element is everything from
    (including) the element's start tag to
    (including) the element's end tag.
    An element can contain:

    ◦   other elements
    ◦   text
    ◦   attributes
    ◦   or a mix of all of the above...
XML Naming Rules
   XML elements must follow these naming
    rules:

    ◦ Names 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 spaces
    ◦ Any name can be used, no words are reserved
XML Elements are Extensible
• XML elements can be extended to carry more
  information.
         <note>
         <to>Tove</to>
         <from>Jani</from>
         <body>Don't forget me this
         weekend!</body>
         </note>

         <note>
         <date>2008-01-10</date>
         <to>Tove</to>
         <from>Jani</from>
         <heading>Reminder</heading>
         <body>Don't forget me this
         weekend!</body>
         </note>
XML Attributes
   XML elements can have attributes, just like HTML.
   Attributes provide additional information about an
    element.
   In HTML, attributes provide additional information
    about elements:
     <img src="computer.gif">
     <a href="demo.asp">
   In the example below, the file type is irrelevant to
    the data, but can be important to the software that
    wants to manipulate the element:
      <file type="gif">computer.gif</file>
XML Attributes Must be
Quoted
   Either single or double quotes can be used. For a person's
    sex, the person element can be written like this:
         <person sex="female">

   or like this:
         <person sex='female'>

   If the attribute value itself contains double quotes you can use
    single quotes, like in this example:

         <gangster name='George "Shotgun" Ziegler'>

   or you can use character entities:
         <gangster name="George &quot; Shotgun&quot; Ziegler">
XML Elements vs. Attributes
<person sex="female">           Attribute
  <firstname>Anna</firstname>
  <lastname>Smith</lastname>
</person>



<person>
  <sex>female</sex>             Element
  <firstname>Anna</firstname>
  <lastname>Smith</lastname>
</person>


 *Authors recommends use as Elements
Using XML Attributes
   Some of the problems with using attributes are:
    ◦ attributes cannot contain multiple values (elements can)
    ◦ attributes cannot contain tree structures (elements can)
    ◦ attributes are not easily expandable (for future changes)

   Attributes are difficult to read and maintain. Use
    elements for data. Use attributes for information that is
    not relevant to the data.

Example using only attributes:

      <note day="10" month="01" year="2008"
      to="Tove" from="Jani" heading="Reminder"
      body="Don't forget me this weekend!“>

      </note>
XML Validation
    XML with correct syntax is "Well Formed" XML.


                   • A "Well Formed" XML document has
                     correct XML syntax.
                   • Use the correct syntax rules.
                   • XML documents must have a root element


•    XML elements must have a closing tag
•    XML tags are case sensitive
•    XML elements must be properly nested
•    XML attribute values must be quoted
XML validated against a DTD is "Valid"
    XML.

•    A "Valid" XML document is a "Well Formed" XML
     document, which also conforms to the rules of a
     Document Type Definition (DTD)
The purpose of a DTD is to define the structure
          of an XML document. It defines the structure
          with a list of legal elements:

               <!DOCTYPE note

XML DTD        [
               <!ELEMENT note
               (to,from,heading,body)>
               <!ELEMENT to (#PCDATA)>
               <!ELEMENT from (#PCDATA)>
               <!ELEMENT heading (#PCDATA)>
               <!ELEMENT body (#PCDATA)>
               ]>



            W3C supports an XML-based alternative to
            DTD:
            <xs:element name="note">

XML         <xs:complexType>
             <xs:sequence>
              <xs:element name="to" type="xs:string"/>
Schema        <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>
Viewing XML Files
 Raw XML files can be viewed in all
  major browsers.
 If an erroneous XML file is
  opened, the browser will report the
  error.
 The XML document will be displayed
  with color-coded root and child
  elements. A plus (+) or minus sign (-)
  to the left of the elements can be
  clicked to expand or collapse the
Displaying XML with CSS
 With CSS (Cascading Style Sheets)
  you can add display information to an
  XML document.
 It is possible to use CSS to format an
  XML document.
 Let’s see an example of how to use a
  CSS style sheet to format an XML
  document.
THANKS…… And let’s build together
some XML 

Weitere ähnliche Inhalte

Was ist angesagt?

Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controlsGuddu gupta
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraintsmadhav bansal
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaMohammad Imam Hossain
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
ASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptxASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptxEdFeranil
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLEVraj Patel
 
Architecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independenceArchitecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independenceAnuj Modi
 
Relational algebra in DBMS
Relational algebra in DBMSRelational algebra in DBMS
Relational algebra in DBMSArafat Hossan
 
7. Relational Database Design in DBMS
7. Relational Database Design in DBMS7. Relational Database Design in DBMS
7. Relational Database Design in DBMSkoolkampus
 
Database Design for News App
Database Design for News AppDatabase Design for News App
Database Design for News Appscubeuser31
 
Dbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureDbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureAmiya9439793168
 
ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...Raj vardhan
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c languagetanmaymodi4
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data ModelSmriti Jain
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts Bharat Kalia
 

Was ist angesagt? (20)

Asp.NET Validation controls
Asp.NET Validation controlsAsp.NET Validation controls
Asp.NET Validation controls
 
Integrity Constraints
Integrity ConstraintsIntegrity Constraints
Integrity Constraints
 
PHP FUNCTIONS
PHP FUNCTIONSPHP FUNCTIONS
PHP FUNCTIONS
 
Sql tutorial
Sql tutorialSql tutorial
Sql tutorial
 
DBTG MODEL
DBTG MODELDBTG MODEL
DBTG MODEL
 
DBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational SchemaDBMS 3 | ER Diagram to Relational Schema
DBMS 3 | ER Diagram to Relational Schema
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Xml
XmlXml
Xml
 
ASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptxASSEMBLY LANGUAGE.pptx
ASSEMBLY LANGUAGE.pptx
 
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
FUNCTION DEPENDENCY  AND TYPES & EXAMPLEFUNCTION DEPENDENCY  AND TYPES & EXAMPLE
FUNCTION DEPENDENCY AND TYPES & EXAMPLE
 
Architecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independenceArchitecture of-dbms-and-data-independence
Architecture of-dbms-and-data-independence
 
Relational algebra in DBMS
Relational algebra in DBMSRelational algebra in DBMS
Relational algebra in DBMS
 
Code generation
Code generationCode generation
Code generation
 
7. Relational Database Design in DBMS
7. Relational Database Design in DBMS7. Relational Database Design in DBMS
7. Relational Database Design in DBMS
 
Database Design for News App
Database Design for News AppDatabase Design for News App
Database Design for News App
 
Dbms 3: 3 Schema Architecture
Dbms 3: 3 Schema ArchitectureDbms 3: 3 Schema Architecture
Dbms 3: 3 Schema Architecture
 
ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...ER to relational Mapping: Data base design using ER to relational language. C...
ER to relational Mapping: Data base design using ER to relational language. C...
 
Operators and expressions in c language
Operators and expressions in c languageOperators and expressions in c language
Operators and expressions in c language
 
Database : Relational Data Model
Database : Relational Data ModelDatabase : Relational Data Model
Database : Relational Data Model
 
PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts PL/SQL Introduction and Concepts
PL/SQL Introduction and Concepts
 

Ähnlich wie Xml intro1 (20)

Xml
XmlXml
Xml
 
paper about xml
paper about xmlpaper about xml
paper about xml
 
Xml 1
Xml 1Xml 1
Xml 1
 
Introduction to xml schema
Introduction to xml schemaIntroduction to xml schema
Introduction to xml schema
 
Xml
XmlXml
Xml
 
XML
XMLXML
XML
 
XML DTD Validate
XML DTD ValidateXML DTD Validate
XML DTD Validate
 
xml.pptx
xml.pptxxml.pptx
xml.pptx
 
Xml iet 2015
Xml iet 2015Xml iet 2015
Xml iet 2015
 
Xml material
Xml materialXml material
Xml material
 
Xml material
Xml materialXml material
Xml material
 
Xml material
Xml materialXml material
Xml material
 
XML
XMLXML
XML
 
Xml and DTD's
Xml and DTD'sXml and DTD's
Xml and DTD's
 
Xsd
XsdXsd
Xsd
 
Xsd
XsdXsd
Xsd
 
Xml 150323102007-conversion-gate01
Xml 150323102007-conversion-gate01Xml 150323102007-conversion-gate01
Xml 150323102007-conversion-gate01
 
XML Presentation-2
XML Presentation-2XML Presentation-2
XML Presentation-2
 
Introduction to xml
Introduction to xmlIntroduction to xml
Introduction to xml
 
Unit 5 xml (1)
Unit 5   xml (1)Unit 5   xml (1)
Unit 5 xml (1)
 

Mehr von Alfonso Gabriel López Ceballos (8)

J meter chapter1
J meter chapter1J meter chapter1
J meter chapter1
 
J unit4
J unit4J unit4
J unit4
 
Unfuddle usage guide 2
Unfuddle usage guide 2Unfuddle usage guide 2
Unfuddle usage guide 2
 
Capacitacion xquery
Capacitacion xqueryCapacitacion xquery
Capacitacion xquery
 
Xpath presentation
Xpath presentationXpath presentation
Xpath presentation
 
Pruebas funcionales
Pruebas funcionalesPruebas funcionales
Pruebas funcionales
 
Metodologia scrum actualizada qa
Metodologia scrum actualizada qaMetodologia scrum actualizada qa
Metodologia scrum actualizada qa
 
Mitos
MitosMitos
Mitos
 

Xml intro1

  • 2. Definition  XML stands for EXtensible Markup Language  XML is a markup language much like HTML  XML was designed to carry data, to transport and store data, not to display data  XML tags are not predefined. You must define your own tags  XML is designed to be self-descriptive The best description of XML is: “XML is a software and hardware-independent tool for carrying information”.
  • 3. XML & HTML  XML is not a replacement for HTML.  XML and HTML were designed with different goals: ◦ XML was designed to transport and store data, with focus on what data is ◦ HTML was designed to display data, with focus on how data looks ◦ HTML is about displaying information, while XML is about carrying information.
  • 4. First Example <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>  The note above is quite self-descriptive. It has sender and receiver information, it also has a heading and a message body.
  • 5. XML Tags  The tags in the example above (like <to> and <from>) are not defined in any XML standard. These tags are "invented" by the author of the XML document.  That is because the XML language has no predefined tags.  The tags used in HTML are predefined. HTML documents can only use tags defined in the HTML standard (like <p>, <h1>, etc.).  XML allows the author to define his/her own tags and his/her own document structure.
  • 6. XML Main Features XML Simplifies Data Transport Exchanging data as XML greatly reduces this complexity, since the data can be read by different incompatible applications. JAVA PHP DOC. XML .NET
  • 7. XML Separates Data from HTML If you need to display dynamic data in your HTML document, it will take a lot of work to edit the HTML each time the data changes. With XML, data can be stored in separate XML files. This way you can concentrate on using HTML/CSS for display and layout, and be sure that changes in the underlying data will not require any changes to the HTML..
  • 8. XML Makes Your Data More Available Different applications can access your data, not only in HTML pages, but also from XML data sources. With XML, your data can be available to all kinds of "reading machines" (Handheld computers, voice machines, news feeds, etc), and make it more available for blind people, or people with other disabilities.
  • 9. XML Simplifies Platform Changes XML data is stored in text format. This makes it easier to expand or upgrade to new operating systems, new applications, or new browsers, without losing data. XML Simplifies Data Sharing In the real world, computer systems and databases contain data in incompatible formats.
  • 10. XML Tree  XML documents form a tree structure that starts at "the root" and branches to "the leaves".
  • 11. Tree Structure  XML documents must contain a root element. This element is "the parent" of all other elements.  The elements in an XML document form a document tree. The tree starts at the root and branches to the lowest level of the tree.  All elements can have sub elements (child elements). <root> <child> <subchild attribute=”value”>.....</subchild> </child> </root>
  • 12. XML Syntax Rules  All XML Elements Must Have a Closing Tag.  XML Tags are Case Sensitive.  XML Elements Must be Properly Nested.  XML Documents Must Have a Root Element.  XML Attribute Values Must be Quoted. <root> <child> <subchild attribute=”value”>value #1</subchild> </child> </root>
  • 13. XML Elements  An XML element is everything from (including) the element's start tag to (including) the element's end tag. An element can contain: ◦ other elements ◦ text ◦ attributes ◦ or a mix of all of the above...
  • 14. XML Naming Rules  XML elements must follow these naming rules: ◦ Names 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 spaces ◦ Any name can be used, no words are reserved
  • 15. XML Elements are Extensible • XML elements can be extended to carry more information. <note> <to>Tove</to> <from>Jani</from> <body>Don't forget me this weekend!</body> </note> <note> <date>2008-01-10</date> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note>
  • 16. XML Attributes  XML elements can have attributes, just like HTML.  Attributes provide additional information about an element.  In HTML, attributes provide additional information about elements: <img src="computer.gif"> <a href="demo.asp">  In the example below, the file type is irrelevant to the data, but can be important to the software that wants to manipulate the element: <file type="gif">computer.gif</file>
  • 17. XML Attributes Must be Quoted  Either single or double quotes can be used. For a person's sex, the person element can be written like this: <person sex="female">  or like this: <person sex='female'>  If the attribute value itself contains double quotes you can use single quotes, like in this example: <gangster name='George "Shotgun" Ziegler'>  or you can use character entities: <gangster name="George &quot; Shotgun&quot; Ziegler">
  • 18. XML Elements vs. Attributes <person sex="female"> Attribute <firstname>Anna</firstname> <lastname>Smith</lastname> </person> <person> <sex>female</sex> Element <firstname>Anna</firstname> <lastname>Smith</lastname> </person> *Authors recommends use as Elements
  • 19. Using XML Attributes  Some of the problems with using attributes are: ◦ attributes cannot contain multiple values (elements can) ◦ attributes cannot contain tree structures (elements can) ◦ attributes are not easily expandable (for future changes)  Attributes are difficult to read and maintain. Use elements for data. Use attributes for information that is not relevant to the data. Example using only attributes: <note day="10" month="01" year="2008" to="Tove" from="Jani" heading="Reminder" body="Don't forget me this weekend!“> </note>
  • 20. XML Validation XML with correct syntax is "Well Formed" XML. • A "Well Formed" XML document has correct XML syntax. • Use the correct syntax rules. • XML documents must have a root element • XML elements must have a closing tag • XML tags are case sensitive • XML elements must be properly nested • XML attribute values must be quoted
  • 21. XML validated against a DTD is "Valid" XML. • A "Valid" XML document is a "Well Formed" XML document, which also conforms to the rules of a Document Type Definition (DTD)
  • 22. The purpose of a DTD is to define the structure of an XML document. It defines the structure with a list of legal elements: <!DOCTYPE note XML DTD [ <!ELEMENT note (to,from,heading,body)> <!ELEMENT to (#PCDATA)> <!ELEMENT from (#PCDATA)> <!ELEMENT heading (#PCDATA)> <!ELEMENT body (#PCDATA)> ]> W3C supports an XML-based alternative to DTD: <xs:element name="note"> XML <xs:complexType> <xs:sequence> <xs:element name="to" type="xs:string"/> Schema <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. Viewing XML Files  Raw XML files can be viewed in all major browsers.  If an erroneous XML file is opened, the browser will report the error.  The XML document will be displayed with color-coded root and child elements. A plus (+) or minus sign (-) to the left of the elements can be clicked to expand or collapse the
  • 24. Displaying XML with CSS  With CSS (Cascading Style Sheets) you can add display information to an XML document.  It is possible to use CSS to format an XML document.  Let’s see an example of how to use a CSS style sheet to format an XML document.
  • 25. THANKS…… And let’s build together some XML 