INLS161-001 | Spring 2018

Class Session: Wednesday Feb 14, 2018


Preparation for this Session


To familiarize yourselves with XML, read from Web Design in a Nutshell, 3rd Edition.

Chapter 7. Introduction to XML

top/reload prep panel

❤️ Friendly Valentine's Day reminder: If you have at least two blog posts (1 intro and 1 from newsletter) by tomorrow morning at 6:00 a.m., you will not permanently lose points on your value added grade! 😀

A brief look at JSON

According to the author of this post, Stop Comparing JSON and XML, JSON is a bicycle and XML is a $226,900 Mercedes AMG S65. There is nothing wrong with a bicycle: it can be the best form of transport in a densely populated area. But on the autobahn, go for the Mercedes. We will take a quick tour of JSON and learn how to integrate it with javascript, then we will look a a more complex example using XML.

But first a quick comparison, (in spite of the admonition to stop comparing them):

  "id": 2355,
  "title": "LINUX Pocket Guide",
  "author": "Daniel J. Barrett",
  "published": {
    "by": "O'Reilly Media, Inc.",
    "year": 2012

A similar document would look like this in XML:

<?xml version="1.0"?>
<book id="2355">
  <title>LINUX Pocket Guide</title>
  <author>Daniel J. Barrett</author>
    <by>O'Reilly Media, Inc.</by>

JSON is a a bit more compact and a little easier to read, but these are simple comparsions.

eXtensible Markup Language

Extensible: it enables the creation of new sets of tags for domain specific content (no limit to element types)

eXtensible Markup Language (XML) is used to describe data. The XML standard is a flexible way to create information formats and electronically share structured data via the public Internet, as well as via corporate networks.

XML code, a formal recommendation from the World Wide Web Consortium (W3C), is similar to Hypertext Markup Language (HTML). Both XML and HTML contain markup symbols to describe page or file contents. HTML code describes Web page content (mainly text and graphic images) only in terms of how it is to be displayed and interacted with.

XML Defines models of document types

XML data is known as self-describing or self-defining, meaning that the structure of the data is embedded with the data, thus when the data arrives there is no need to pre-build the structure to store the data; it is dynamically understood within the XML. The XML format can be used by any individual or group of individuals or companies that want to share information in a consistent way. XML is actually a simpler and easier-to-use subset of the Standard Generalized Markup Language (SGML), which is the standard to create a document structure.

The basic building block of an XML document is an element, defined by tags. An element has a beginning and an ending tag. All elements in an XML document are contained in an outermost element known as the root element. XML can also support nested elements, or elements within elements. This ability allows XML to support hierarchical structures. Element names describe the content of the element, and the structure describes the relationship between the elements.

XML documents are transformed to meet the requirements of specific implementations

An XML document is considered to be "well formed" (that is, able to be read and understood by an XML parser) if its format complies with the XML specification, if it is properly marked up, and if elements are properly nested. XML also supports the ability to define attributes for elements and describe characteristics of the elements in the beginning tag of an element.

For example, XML documents can be very simple, such as the following:

<?xml version="1.0" standalone="yes"?>
<greeting>Hey, what's this page about?</greeting>
<response>It's about something we need to know!</response>

XML's power resides in its simplicity. It can take large chunks of information and consolidate them into an XML document - meaningful pieces that provide structure and organization to the information.


Lawrence Jones

Office hours by appointment.