Skip to content


Below is an example of a manuscript encoded with XML using the TEI P5 Guidelines.

I chose a page from the diaries of Marjory Fleming to encode. Marjory Fleming was a Scottish child writer and poet who lived in the early nineteenth century and died at only 8 years old. This diary entry offers her thoughts after encountering Macbeth.

Here’s the image of the page I encoded:

Page from the diary of Marjory Fleming in her handwriting

Here is the encoded output using XML with XSLT:

And here is the raw XML:

<?xml version="1.0" encoding="UTF-8"?>
<?xml-model href="" type="application/xml" schematypens=""?>
<?xml-model href="" type="application/xml"
<TEI xmlns="">
            <title>Diary of Marjory Fleming: sample page</title>
               <persName>Marjory Fleming</persName>
               <resp>Encoded by</resp>
               <name xml:id="SB">Suzanne Black</name>
            <p>For example purposes only; not to distribute.</p>
            <p>National Library of Scotland</p>
         <person xml:id="Queen01" role="nobility">
            <persName xml:lang="en">Mary, Queen of Scots</persName>
            <birth when="1542-12-08">8 December 1542<placeName>
                  <settlement type="building">Linlithgow Palace</settlement>
                  <country key="GBR">United Kingdom</country>
            <death when="1587-02-08">8 February 1587<placeName>
                  <settlement type="building">Fotheringhay Castle</settlement>
                  <country key="GBR">United Kingdom</country>
         <person xml:id="Queen02" role="nobility">
            <persName xml:lang="en">Elizabeth I</persName>
            <birth when="1533-09-07">7 September 1533<placeName>
                  <settlement type="building">Palace of Placentia</settlement>
                  <country key="GBR">United Kingdom</country>
            <death when="1603-03-24">24 March 1603<placeName>
                  <settlement type="building">Richmond Palace</settlement>
                  <country key="GBR">United Kingdom</country>
      <surface xml:id="image01"> </surface>
         <div type="diary_entry">
            <pb n="01" facs="#image01"/>
               <lb/>Macbeth is a fearful play. I pityed
               <lb/><persName ref="#Queen01">Mary Queen of Scots</persName> when the
               <lb/>people held a standard on which
               <lb/>was painted the dead king and
               <lb/>his son kneeling and uttering
               <lb/>these words judge &amp; revenge any
               <lb/>cause O Lord I should not liked to
               <lb/>have been <rs ref="#Queen01">her</rs> but I think it was very
               <lb/>wrong on the people to mock their
               <lb/><rs ref="#Queen01">sovereign &amp; queen</rs>. I have seen
               <lb/><rs ref="#Queen01">her</rs> picture &amp; think <rs>her</rs> most
               <lb/>Beautiful &amp; <persName ref="#Queen02">Angelick Elisabeth</persName>
               <lb/>behaved very crually to poor
               <lb/>poor <persName ref="#Queen01">Mary</persName>.</p>


National Library of Scotland. Diary, letters and poems of Marjory Fleming. National Library of Scotland, 2021.

TEI Consortium, eds. TEI P5: Guidelines for Electronic Text Encoding and Interchange. Version 4.2.2. [Last modified 9 Apr 2021, revision 609a109b1]. TEI Consortium.