Skip to Main Content

University Library

LibGuides

An Introduction to XML and TEI

This guide provides an introduction to XML and the Text Encoding Initiative.

Letter

Here is XML applied to a short letter.


<letter>

   <date>March 15, 2013</date>

   <salutation>Dear <name>Joe</name></salutation>

   <paragraph>How's it going? Some weather we're having! Say hi to <name>Mary</name>!</paragraph>

   <signature>From, <name>Bob</name></signature>

</letter>


This XML is well-formed because it has one element <letter>, which includes all the other elements. Each section of text is properly delimited and none of the elements overlap.  Remember, it cannot be valid because we have not specified a schema against which to validate it, but it follows the basic rules of XML and is thus well-formed.

 

Poem

Below is an example of XML applied to a poem.

<poem>

   <head>XXI.</head>

   <title>A Book.</title>

   <stanza>

      <l>He ate and drank the precious words,</l>

      <l>His Spirit grew robust;</l>

      <l>He knew no more that he was poor,</l>

      <l>Nor that his frame was dust.<l>

      <l>He danced along the dingy days,</l>

      <l>And this bequest of wings</l>

      <l>Was but a book. What liberty</l>

      <l>A loosened Spirit brings!</l>

   </stanza>

</poem>

Here again, the XML is well-formed because it has one element <poem>, which includes all the other elements. Each section of text is properly delimited and none of the elements overlap.  Remember, it cannot be valid because we have not specified a schema against which to validate it, but it follows the basic rules of XML and is thus well-formed.