1 / 30

How do I use HTML and XML to present information?

Learn how to use HTML and XML markup languages to present information on the web. Explore HTML components, attributes, and elements, as well as the basics of XML document structure and syntax.

rosemarys
Download Presentation

How do I use HTML and XML to present information?

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. How do I use HTML and XML to present information?

  2. Markup Languages • Set of commands that tell a program how to display content • Written in plain text • Browser converts markup language to a visual display • HTML, XML are markup languages

  3. Basic HTML Document <HTML> <HEAD> <TITLE>The Title</TITLE> </HEAD> <BODY BGCOLOR=“#CCFFFF”> Here is the content of the page </BODY> </HTML>

  4. HTML Components • Tags are enclosed in < > • Tags are closed with a / • Elements are an opened and closed tag • Example <TITLE>The Title</TITLE>

  5. HTML Attributes • Tags can have attributes • BGCOLOR is an example • Name value pairs • BGCOLOR=“#CCFFFF” • BGCOLOR is the name, #CCFFFF is the value • Minimized attributes have no value • SELECTED • BGFIXED

  6. HTML Components • In HTML each tag has a meaning. e.g. <b>Hello</b> <b>bold</b> and <i>italicized</i> • You can embed you data in these tags to present the information on the Web. • This structure is defined in a DTD, a Document Type Definition

  7. XML Basics • XML - EXtensible Markup Language • XML is much like HTML • Elements and tags • Developer can create new tags as needed • Document content is described rather than format • Must be well formed (more about this later)

  8. XML Document Sections An XML document can have the following three sections • Prolog (optional) Stuff before the top-level, start-tag is called the "prolog". • Body • Epilog (optional) Stuff after the top-level, end-tag is called the "epilog"

  9. Sample XML File <?xml version="1.0"?> <Person> <name>Alan</name> <address>Abbeydale road</address> <city>Sheffield</city> <gender>Male</gender> </Person> <!--This is a comment--> Prolog BODY Epilog

  10. Another example of the same XML File <Person> <name>Sarah</name> <address>42, Oldbridge Court</address> <address>Oldbridge Road</address> <city>London</city> <gender>Female</gender> </Person>

  11. Creating an XML Document Overview • Research XML Applications • Create a data model • Write the ‘XML’ document • Test the XML document

  12. XML Snippet <customer> <name>John Smith</name> <age>35</age> </customer>

  13. XML Entities and Data • Entities are XML files or documents • Data is part of an XML document • May be parsed or unparsed • Parsed holds all character data • Unparsed holds character or non character data

  14. XML Names • Attributes and elements will be named • Standard programming rules apply • No spaces • Must begin with a letter • No _ or : • Name must not start with XML in any case

  15. XML Elements • Fields in the XML document • Elements are often nested hierarchically • Must be nested correctly • All tags must have an ending tag • Elements may have attributes

  16. XML Attributes • Must be in name-value pair format • Height=“65” • Any element may have an attribute • Two reserved attributes • Xml:space and xml:lang

  17. XML Character Data • Character data is text in the document, not markup tags • Certain characters are reserved and must be entered using character references • &amp; &lt; &gt; are typical character references

  18. XML Comments • Just like HTML comments <!--This is a comment-->

  19. Tools used to develop HTML & XML Documents HTML – You can develop HTML documents in FrontPage or Dreamweaver XML - You can develop XML documents in XMLSpy

  20. The main difference between XML and HTML

  21. XML Syntax The syntax rules of XML are very simple and very Strict. Lets start by reviewing a simple XML file <?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>

  22. A simple XML file containing data about an Email This line defines that this is an XML file <?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> This is the root element These are the child elements

  23. The same XML file with an error • <?xml version="1.0" encoding="ISO-8859-1" ?> • <note> • <to>Tove</to> • <from>Jani</Ffrom> • <heading>Reminder</heading> • <body>Don't forget me this weekend!</body> • </note> • The XML page cannot be displayed cannot view XML input using XSL style sheet. Please correct the error and then click the Refresh button, or try again later. • End tag 'Ffrom' does not match the start tag 'from'. Line 5, Position 14 • <from>Jani</Ffrom> -------------^

  24. All XML elements must have a closing tag In HTML, you would write <p> This is a paragraph In XML, you would write <p> This is a paragraph </p> XML Tags are case sensitive This is incorrect <Student> Phil</student> This is correct <Student> Phil</Student> XML Syntax

  25. All XML elements must be properly nested This is incorrect <note> <To> Tove</note></To> This is correct <note> <To> Tove</To></note> All XML documents must have a root tag and only one root tag <root> <child> <subchild> </subchild> </child> </root> XML Syntax

  26. XML ELEMENTS • XML Elements have Relationships • XML elements have a child parent relationship • Lets review the following structure • Book Title: My First XML • Chapter 1: Introduction to XML • What is HTML • What is XML • Chapter 2: XML Syntax • Elements must have a closing tag • Elements must be properly nested

  27. XML ELEMENTS The book details structure in XML would look like <book> <title>My First XML</title> <prod id="33-657" media="paper"></prod> <chapter>Introduction to XML <para>What is HTML</para> <para>What is XML</para> </chapter> <chapter>XML Syntax <para>Elements must have a closing tag</para> <para>Elements must be properly nested</para> </chapter> </book>

  28. Book is the root element. Title, prod, and chapter are child elements of book. Book is the parent element of title, prod, and chapter. Title, prod, and chapter are siblings (or sister elements) because they have the same parent. XML ELEMENTS

  29. "Well Formed" XML documents A "Well Formed" XML document has correct XML syntax. A "Well Formed" XML document is a document that conforms to the XML syntax rules that were described in the previous slides

  30. XML was not designed to DO anything Maybe it is a little hard to understand, but XML does not DO anything. XML is created to structure, store, and to send information. The following example is a note to Tove from Jani, stored as XML: <note> <to>Tove</to> <from>Jani</from> <heading>Reminder</heading> <body>Don't forget me this weekend!</body></note> The note has a header, and a message body. It also has sender and receiver information. But still, this XML document does not DO anything. It is just pure information wrapped in XML tags. Someone must write a piece of software to send, receive, or display it.

More Related