eXtensible Markup Language
Markup Language                    GML             SGMLWML      ..ML
Markup LanguageA Markup Language is a computerlanguage that specifies the structureand content of a document by breakingth...
XMLXML stands for eXtensible Markup LanguageXML is a markup language much like HTMLIt’s a new markup language,developed by...
XML & HTMLHTML and XML were designed withdifferent goals  HTML was designed to display data and to  focus on how data look...
XML & HTMLHTML tag : pre-defined tag   <b>John</b>XML tag : user-defined tag   <Name>John</Name>
Markup Language Example                    Markup                   Language      HTML                                  XM...
XML Example                                     XMLxml01.xml<?xml version=“1.0”?><employee><id>001</id><name>Prapoj Sukman...
Element Structure              Element Name      <tag>       Content      </tag>Open Tag(start-tag)          Close Tag(end...
XML Structure<?xml version=“1.0” ?>             root<root> <child>   <sub_child>   </sub_child> </child>                ch...
XML File StructureFile name : *.xml                       Prolog                    Document Elements
PrologXML Declaration  <?xml version=“1.0”?>Document Type Declaration  <!DOCTYPE PurchaseOrder SYSTEM “po.dtd”>Processing ...
Document Elements<employee> <id>001</id> <name>Prasit Lee</name> <city>Bangkok</city> <email>prasitl@hotmail.com</email></...
XML File Structure : Prolog  File name : *.xml1. XML Declaration                   Prolog2. Document Type Declaration (DTD...
XML Examplexml01.xml<?xml version=“1.0” ?><employee> <id>001</id> <name>Prasit Lee</name> <city>Bangkok</city> <email>pras...
Thai Language XML Examplexml01th.xml<?xml version=“1.0” encoding=“windows-874”?><employee>  <id>001</id>  <name>ประสิ ทธิ ...
XML Benefits       Self-describe Data        Data Exchange                                           XML BenefitsMessaging...
Text File & XML File   employee.txt                 employee.xml     Text File                     XML File               ...
Data Exchange Example   DB Server 1                               DB Server 2XML Parser                employee.xml       ...
XML ProcessorAfter the XML document is created, it needsto be evaluated by an application known asan XML processor or XML ...
Well-Formed XML“A Well-Formed XML document contains no syntaxerrors and satisfies the specifications for XML codesas laid ...
1. Root Element               <?xml version=“1.0” ?>               <employee>                 <id>001</id>                ...
2. Element NamingXML elements must follow these naming rules  Names can contain letters,numbers, and  other characters.Nam...
Element Naming : Example                 <-Company>                 <9Company><Company>        <.My_company><_Company>    ...
3. Closed Tag<?xml version=“1.0” ?><employee><id>001</id><name>Prapoj Sukmanont</name><city>Bangkok</city><email>prapojs@h...
4. Proper Nesting Tag<ID>                <ID> <name>                 <name> </ID>                 </name></name>          ...
5. Case-sensitive<ID>                   <ID> <name>                    <name> </Name>                    </name></ID>     ...
6. Attribute Value                    <employee id=“001”>                     <name><employee id=001>    </name> <name>   ...
Element Attribute     An attribute describes a feature or characteristic of an element .Attributes     are often used to p...
Well-Formed XML Example                                       Well-Formed                                           XML xm...
XML Element TypesNormal element <Name>Prasit Lee </Name>Empty element <telephone></telephone> <telephone/>
Element Content
Element Content<Start-tag>   Content   </End-tag>    Nested element    Character data    Reference Entity    CDATA    Comm...
1. Nested Element…<BOOK>  <TITLE> XML Book </TITLE>  <AUTHOR>Prasit Lee </AUTHOR></BOOK>
2. Character Data…<TITLE> XML Book </TITLE><AUTHOR>Prasit Lee </AUTHOR>…
3. Entity Reference&      &amp;<      &lt;>      &gt;“      &quot;‘      &apos;
XML Examplexmlerror1.xml<?xml version=“1.0” ?><Example>  <Statement>if x < y </Statement></Example>                    Not...
XML Examplexml03.xml<?xml version=“1.0” ?><Example>  <Statement>if x &lt; y </Statement></Example>
4. CDATA Sectionxml04.xml<?xml version=“1.0”?><Example>  <Statement>   <![CDATA[     if x > y and a < b     ]]>  </Stateme...
CDATASometimes, an XML document needs to store largeblocks of text containing the < and > symbols. Inthat case, it would b...
5. Comment…<BOOK>  <!-- This is comment create by “Prasit” 03.02.2012-->  <TITLE> XML Book </TITLE>  <AUTHOR>Prasit Lee </...
Upcoming SlideShare
Loading in...5
×

Xml overview

1,233

Published on

โดย อ.ประพจน์ สุขมานนท์

Published in: Education
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total Views
1,233
On Slideshare
0
From Embeds
0
Number of Embeds
6
Actions
Shares
0
Downloads
9
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Xml overview

  1. 1. eXtensible Markup Language
  2. 2. Markup Language GML SGMLWML ..ML
  3. 3. Markup LanguageA Markup Language is a computerlanguage that specifies the structureand content of a document by breakingthe document down into the series ofelements
  4. 4. XMLXML stands for eXtensible Markup LanguageXML is a markup language much like HTMLIt’s a new markup language,developed by theW3C(www.w3.org),mainly to overcome limitationsin HTMLXML was designed to describe dataXML tags are not predefined in XML.You mustdefine your own tags
  5. 5. XML & HTMLHTML and XML were designed withdifferent goals HTML was designed to display data and to focus on how data looks XML was designed to describe data and to focus on what data isHTML is about displaying information,XML is about describing information
  6. 6. XML & HTMLHTML tag : pre-defined tag <b>John</b>XML tag : user-defined tag <Name>John</Name>
  7. 7. Markup Language Example Markup Language HTML XML<b>025447891</b> <myphonenumber>025447891</myphonenumber>
  8. 8. XML Example XMLxml01.xml<?xml version=“1.0”?><employee><id>001</id><name>Prapoj Sukmanont</name><city>Bangkok</city><email>prapojs@hotmail.com</email></employee>
  9. 9. Element Structure Element Name <tag> Content </tag>Open Tag(start-tag) Close Tag(end-tag)
  10. 10. XML Structure<?xml version=“1.0” ?> root<root> <child> <sub_child> </sub_child> </child> child child <child> <sub_child> </sub_child> sub_child sub_child </child></root>
  11. 11. XML File StructureFile name : *.xml Prolog Document Elements
  12. 12. PrologXML Declaration <?xml version=“1.0”?>Document Type Declaration <!DOCTYPE PurchaseOrder SYSTEM “po.dtd”>Processing Instruction(PI) <?xml-stylesheet type=“text/css” href=“test.css”?>
  13. 13. Document Elements<employee> <id>001</id> <name>Prasit Lee</name> <city>Bangkok</city> <email>prasitl@hotmail.com</email></employee>
  14. 14. XML File Structure : Prolog File name : *.xml1. XML Declaration Prolog2. Document Type Declaration (DTD)3. Processing Instruction (PI) Document Elements
  15. 15. XML Examplexml01.xml<?xml version=“1.0” ?><employee> <id>001</id> <name>Prasit Lee</name> <city>Bangkok</city> <email>prasitl@hotmail.com</email></employee>
  16. 16. Thai Language XML Examplexml01th.xml<?xml version=“1.0” encoding=“windows-874”?><employee> <id>001</id> <name>ประสิ ทธิ ลี</name> <city>กรุ งเทพ</city> <email>prasitl@hotmail.com</email></employee>
  17. 17. XML Benefits Self-describe Data Data Exchange XML BenefitsMessaging Format for Application So on…(RSS, ebXML, XML Applications…) CML, MathML, MusicML, VoiceML …
  18. 18. Text File & XML File employee.txt employee.xml Text File XML File <?xml version=“1.0” ?>1,John,Bangkok <employee>2,David,New York <id>1</id>3,Peter,London <name>John</name> <city>Bangkok</city> <id>2</id> <name>David</name> <city>New York</city> <id>3</id> <name>Peter</name> <city>London</city> </employee>
  19. 19. Data Exchange Example DB Server 1 DB Server 2XML Parser employee.xml XML Parser XML File Database <?xml version=“1.0” ?> Database <employee> <id>1</id> <name>John</name> <city>Bangkok</city> <id>2</id> <name>David</name> <city>New York</city> <id>3</id> <name>Peter</name> <city>London</city> </employee>
  20. 20. XML ProcessorAfter the XML document is created, it needsto be evaluated by an application known asan XML processor or XML parserPart of the function of the parser is tointerpret the document’s code and verify thatit satisfies all of the XML specifications fordocument structure and syntaxMicrosoft developed an XML parser calledMSXML (msxml.exe) for its Internet Explorerbrowser
  21. 21. Well-Formed XML“A Well-Formed XML document contains no syntaxerrors and satisfies the specifications for XML codesas laid out by W3C”
  22. 22. 1. Root Element <?xml version=“1.0” ?> <employee> <id>001</id> <name>Prapoj Sukmanont</name>Root Element <city>Bangkok</city> <email>prapojs@hotmail.com</email> </employee>
  23. 23. 2. Element NamingXML elements must follow these naming rules Names can contain letters,numbers, and other characters.Names must not start with a number or other punctuation characters Names must not start with the letter xml(or XML or Xml ...) Names cannot contain space,(*,? And +) Avoid “-” and “.” in names The “:” should not be used in element names
  24. 24. Element Naming : Example <-Company> <9Company><Company> <.My_company><_Company> <Name*><My_company> <Name?><First-name> <Name+><Last.name> <xmlbook> <first name> Not OK OK
  25. 25. 3. Closed Tag<?xml version=“1.0” ?><employee><id>001</id><name>Prapoj Sukmanont</name><city>Bangkok</city><email>prapojs@hotmail.com</email></employee>
  26. 26. 4. Proper Nesting Tag<ID> <ID> <name> <name> </ID> </name></name> </ID>
  27. 27. 5. Case-sensitive<ID> <ID> <name> <name> </Name> </name></ID> </ID>
  28. 28. 6. Attribute Value <employee id=“001”> <name><employee id=001> </name> <name> </employee> </name></employee> <employee id=‘001’> <name> </name> </employee>
  29. 29. Element Attribute An attribute describes a feature or characteristic of an element .Attributes are often used to provide additional information about an element .The syntax for adding an attribute to an element is<element_name attribute_name=“Attribute value”> … </element_name> Attribute name constraints: The name must begin with a letter or underscore (_) Space are not allowed in attribute names Attribute names should not begin with the text string “xml”
  30. 30. Well-Formed XML Example Well-Formed XML xml02.xml<?xml version=“1.0” ?><employee><id>001</id><name prefix=“Mr”>Prapoj Sukmanont</name><city>Bangkok</city><email>prapojs@hotmail.com</email></employee>
  31. 31. XML Element TypesNormal element <Name>Prasit Lee </Name>Empty element <telephone></telephone> <telephone/>
  32. 32. Element Content
  33. 33. Element Content<Start-tag> Content </End-tag> Nested element Character data Reference Entity CDATA Comment
  34. 34. 1. Nested Element…<BOOK> <TITLE> XML Book </TITLE> <AUTHOR>Prasit Lee </AUTHOR></BOOK>
  35. 35. 2. Character Data…<TITLE> XML Book </TITLE><AUTHOR>Prasit Lee </AUTHOR>…
  36. 36. 3. Entity Reference& &amp;< &lt;> &gt;“ &quot;‘ &apos;
  37. 37. XML Examplexmlerror1.xml<?xml version=“1.0” ?><Example> <Statement>if x < y </Statement></Example> Not XML Well-formed
  38. 38. XML Examplexml03.xml<?xml version=“1.0” ?><Example> <Statement>if x &lt; y </Statement></Example>
  39. 39. 4. CDATA Sectionxml04.xml<?xml version=“1.0”?><Example> <Statement> <![CDATA[ if x > y and a < b ]]> </Statement></Example>
  40. 40. CDATASometimes, an XML document needs to store largeblocks of text containing the < and > symbols. Inthat case, it would be cumbersome to replace all ofthe < and > symbols with &lt; and &gt; characterreference, the code itself will be difficult to readInstead of using character references, you can placelarge blocks of text into a CDATA sectionA CDATA section is a large block text that the XMLprocessor interprets only a text <![CDATA[ Text block ]]>
  41. 41. 5. Comment…<BOOK> <!-- This is comment create by “Prasit” 03.02.2012--> <TITLE> XML Book </TITLE> <AUTHOR>Prasit Lee </AUTHOR></BOOK>
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×