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.