WEB PROGRAMMING XML Dr.M.UMADEVI ASSISTANT PROFESSOR DEPARTMENT OF CS SACWC CUMBUM
Introduction to XML  XML was designed to describe data.  HTML was designed to display data.  XML is not a replacement for HTML.  XML and HTML were designed with different goals:  XML was designed to describe 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.
XML Simplifies Data Sharing  In the real world, computer systems and databases contain data in incompatible formats.  XML data is stored in plain text format. This provides a software- and hardware- independent way of storing data.  This makes it much easier to create data that can be shared by different applications
XML Simplifies Data Transport  One of the most time-consuming challenges for developers is to exchange data between incompatible systems over the Internet.  Exchanging data as XML greatly reduces this complexity, since the data can be read by different incompatible applications. 
XML Simplifies Platform Changes  Upgrading to new systems (hardware or software platforms), is always time consuming. Large amounts of data must be converted and incompatible data is often lost.  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 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 Tree   An Example XML Document  XML documents use a self-describing and simple syntax:  <?xml version="1.0" encoding="UTF-8"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading>  <body>Don't forget me this weekend!</body> </note>  The first line is the XML declaration. It defines the XML version (1.0).  The next line describes the root element of the document (like saying: "this document is a note"):  <note>  The next 4 lines describe 4 child elements of the root (to, from, heading, and body):  <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body>  And finally the last line defines the end of the root element:
XML Tags are Case Sensitive  XML tags are case sensitive. The tag <Letter> is different from the tag <letter>.  Opening and closing tags must be written with the same case:  <Message>This is incorrect</message> <message>This is correct</message>  Note: "Opening and closing tags" are often referred to as "Start and end tags". Use whatever you prefer. It is exactly the same thing.
Entity References  Some characters have a special meaning in XML.  If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element.  This will generate an XML error:  <message>if salary < 1000 then</message>  To avoid this error, replace the "<" character with an entity reference:  <message>if salary &lt; 1000 then</message>  There are 5 pre-defined entity references in XML:  &lt; < less than &gt; > greater than &amp; & ampersand &apos; ' apostrophe &quot; " quotation mark
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... <bookstore> <book category="CHILDREN"> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="WEB”> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore>
XML Naming Rules XML elements must follow these naming rules: Element names are case-sensitive Element names must start with a letter or underscore Element names cannot start with the letters xml (or XML, or Xml, etc) Element names can contain letters, digits, hyphens, underscores, and periods Element names cannot contain spaces Best Naming Practices Create descriptive names, like this: <person>, <firstname>, <lastname>. Create short and simple names, like this: <book_title> not like this: <the_title_of_the_book>. Avoid "-". If you name something "first-name", some software may think you want to subtract "name" from "first". Avoid ".". If you name something "first.name", some software may think that "name" is a property of the object "first". Avoid ":". Colons are reserved for namespaces (more later).
XML Namespaces In XML, element names are defined by the developer. This often results in a conflict when trying to mix XML documents from different XML applications. This XML carries HTML table information: <table> <tr> <td>Apples</td> <td>Bananas</td> </tr> </table> This XML carries information about a table (a piece of furniture): <table> <name>African Coffee Table</name> <width>80</width> <length>120</length> </table> If these XML fragments were added together, there would be a name conflict. Both contain a <table> element, but the elements have different content and meaning. A user or an XML application will not know how to handle these differences.
XML Encoding XML documents can contain international characters, like Norwegian æøå, or French êèé. To avoid errors, you should specify the encoding used, or save your XML files as UTF- 8. Character Encoding Character encoding defines a unique binary code for each different character used in a document. In computer terms, character encoding are also called character set, character map, code set, and code page. The Unicode Consortium The Unicode Consortium develops the Unicode Standard. Their goal is to replace the existing character sets with its standard Unicode Transformation Format (UTF)
Viewing XML Files <?xml version="1.0" encoding="UTF-8"?> - <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> <?xml version="1.0" encoding="UTF-8"?> <?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>
THANK YOU

Web programming xml

  • 1.
  • 2.
    Introduction to XML XML was designed to describe data.  HTML was designed to display data.  XML is not a replacement for HTML.  XML and HTML were designed with different goals:  XML was designed to describe 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.
  • 3.
    XML Simplifies DataSharing  In the real world, computer systems and databases contain data in incompatible formats.  XML data is stored in plain text format. This provides a software- and hardware- independent way of storing data.  This makes it much easier to create data that can be shared by different applications
  • 4.
    XML Simplifies DataTransport  One of the most time-consuming challenges for developers is to exchange data between incompatible systems over the Internet.  Exchanging data as XML greatly reduces this complexity, since the data can be read by different incompatible applications. 
  • 5.
    XML Simplifies PlatformChanges  Upgrading to new systems (hardware or software platforms), is always time consuming. Large amounts of data must be converted and incompatible data is often lost.  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.
  • 6.
    XML Makes YourData 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. 
  • 7.
    XML Tree   AnExample XML Document  XML documents use a self-describing and simple syntax:  <?xml version="1.0" encoding="UTF-8"?> <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading>  <body>Don't forget me this weekend!</body> </note>  The first line is the XML declaration. It defines the XML version (1.0).  The next line describes the root element of the document (like saying: "this document is a note"):  <note>  The next 4 lines describe 4 child elements of the root (to, from, heading, and body):  <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body>  And finally the last line defines the end of the root element:
  • 8.
    XML Tags areCase Sensitive  XML tags are case sensitive. The tag <Letter> is different from the tag <letter>.  Opening and closing tags must be written with the same case:  <Message>This is incorrect</message> <message>This is correct</message>  Note: "Opening and closing tags" are often referred to as "Start and end tags". Use whatever you prefer. It is exactly the same thing.
  • 9.
    Entity References  Somecharacters have a special meaning in XML.  If you place a character like "<" inside an XML element, it will generate an error because the parser interprets it as the start of a new element.  This will generate an XML error:  <message>if salary < 1000 then</message>  To avoid this error, replace the "<" character with an entity reference:  <message>if salary &lt; 1000 then</message>  There are 5 pre-defined entity references in XML:  &lt; < less than &gt; > greater than &amp; & ampersand &apos; ' apostrophe &quot; " quotation mark
  • 10.
    XML Elements An XMLelement 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... <bookstore> <book category="CHILDREN"> <title>Harry Potter</title> <author>J K. Rowling</author> <year>2005</year> <price>29.99</price> </book> <book category="WEB”> <author>Erik T. Ray</author> <year>2003</year> <price>39.95</price> </book> </bookstore>
  • 11.
    XML Naming Rules XMLelements must follow these naming rules: Element names are case-sensitive Element names must start with a letter or underscore Element names cannot start with the letters xml (or XML, or Xml, etc) Element names can contain letters, digits, hyphens, underscores, and periods Element names cannot contain spaces Best Naming Practices Create descriptive names, like this: <person>, <firstname>, <lastname>. Create short and simple names, like this: <book_title> not like this: <the_title_of_the_book>. Avoid "-". If you name something "first-name", some software may think you want to subtract "name" from "first". Avoid ".". If you name something "first.name", some software may think that "name" is a property of the object "first". Avoid ":". Colons are reserved for namespaces (more later).
  • 12.
    XML Namespaces In XML,element names are defined by the developer. This often results in a conflict when trying to mix XML documents from different XML applications. This XML carries HTML table information: <table> <tr> <td>Apples</td> <td>Bananas</td> </tr> </table> This XML carries information about a table (a piece of furniture): <table> <name>African Coffee Table</name> <width>80</width> <length>120</length> </table> If these XML fragments were added together, there would be a name conflict. Both contain a <table> element, but the elements have different content and meaning. A user or an XML application will not know how to handle these differences.
  • 13.
    XML Encoding XML documentscan contain international characters, like Norwegian æøå, or French êèé. To avoid errors, you should specify the encoding used, or save your XML files as UTF- 8. Character Encoding Character encoding defines a unique binary code for each different character used in a document. In computer terms, character encoding are also called character set, character map, code set, and code page. The Unicode Consortium The Unicode Consortium develops the Unicode Standard. Their goal is to replace the existing character sets with its standard Unicode Transformation Format (UTF)
  • 14.
    Viewing XML Files <?xmlversion="1.0" encoding="UTF-8"?> - <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body> </note> <?xml version="1.0" encoding="UTF-8"?> <?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>
  • 15.

Editor's Notes

  • #2 NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image.