Let’s talk t, p, and r

 So, now that I have decided to take my WordML skills to the next level it also affords me that chance to answer some of the questions that regularly come through my inbox.

Managing the content for the Office Developer Center site has a lot of benefits, and one of them is that I’m in the loop on a lot of questions, both internal and external. One things is clear to me: WordML is “Hot, Hot, Hot” (please name the band that wrote a song with this title. The prize is that I will respect you more for knowing about this great band).


When you save your documents in WordML format and then peek at the XML, you may find the verbosity of the XML and the number of tags a little arresting at first. That’s OK- just relax and know that there are three main workhorses for the bulk of Word markup: give me t, give me a r, give me an p! (you can download the XML schema reference for Office from our download center if you want to truly dig into the schemas). The <t> element encapsulates text. That’s it. Pure and simple. Any and all text goes between <t></t> tags. The <r> element is for runs of text. Often, it contains a bunch of <t> elements (which have all of the text). Informally said, it is a way of grouping <t> elements, applying styles to the run of text etc. The <p> element encapsulates a paragraph of text. No big news here.


Here is some text I typed in Word:


This is some text. We will look at how it gets divided up.

This is a second paragraph with bold!


Here is what the WordML markup looks like (I dropped off declarations, processing instructions, and other preamble info):





        <w:t>This is some text. We will look at how it gets divided up.</w:t>





        <w:t>This is a second paragraph with </w:t>














As you can see, it’s pretty straight-forward. But, why should you care? Well, think XSLT! You can create Word documents from any well-formed XML file. You can turn Word documents into another XML structure. This is a hint of what it’s all about.


Rock on.

Comments (9)

  1. Don R. Watters says:

    Buster Poindexter…

    How you feelin’, Hot, Hot, Hot!

  2. Michael Ames says:

    The Cure.

    But I must take exception with this notion that old 80’s alternative rock makes the best music to program by. Keep your Bono and "The Edge". Want to add energy and subtle genius to your code? Try <a href="http://www.nickelcreek.com/">Nickel Creek</a>.

Skip to main content