15.1. eXtensible Markup Language - XML

XML is a mark-up language. HTML is also a mark-up language. XML looks very similar to HTML, but it is different from XML.

Some of the differences between XML and HTML are:

For more information on XML see https://www.w3schools.com/xml/default.asp.

Here is a sample of an XML document:

<person>
  <name>Chuck</name>
  <phone type="intl">
    +1 734 303 4456
  </phone>
  <email hide="yes" />
</person>

Each pair of opening (e.g., <person>) and closing tags (e.g., <\person>) represents a element or node with the same name as the tag (e.g., person). Each element can have some text, some attributes (e.g., hide), and other nested elements. If an XML element is empty (i.e., has no content), then it may be depicted by a self-closing tag (e.g., <email />).

Often it is helpful to think of an XML document as a tree structure where there is a top/root element (here: person), and other tags (e.g., phone) are drawn as children of their parent elements.

A Tree Representation of XML

15.1.1. Properly Formatted XML

Solve the next couple of problems and think about what are the rules for properly formatted XML.

Put the blocks into order to define just the body of simple XML document that defines a note. A note has a date, subject, and a body in that order. Indent the blocks to show the structure (parent and child).

Put the blocks into order to define just the body of simple XML document that stores information for a message: to, from, time, subject, and body in that order. Indent the blocks to show the structure (parent and child).

You have attempted of activities on this page