lunedì, giugno 25, 2007

Dynamically Generated Word 2003 XML

Generating Word documents on the server? There are probably much more sophisticated methods. However, I’ve been experimenting with creating XML from a webserver as a means of automatically creating Word documents from data in a SharePoint list.

 

I haven’t had a chance to try Word 2007 yet, which promises better XML.

 

*

 

Overview of WordprocessingML [Word 2003 XML Reference]

 

If you save a Microsoft© Office Word 2003 document with the .xml extension, Windows treats the file like any other XML file. When the user double-clicks the file, for example, opens it in the standard XML processor (such as Microsoft Internet Explorer). However, adding the mso-application processing instruction specifies Word as the preferred application for processing the file. As a result, Word opens the XML document when the user double-clicks the document's icon. The following example shows the sample document with the mso-application element added:

 

<?xml version="1.0"?>

<?mso-application progid="Word.Document"?>

<w:wordDocument

    xmlns:w="http://schemas.microsoft.com/office/word/2003/wordml">

<w:body>

    <w:p>

        <w:r>

            <w:t>Hello, World.</w:t>

        </w:r>

    </w:p>

</w:body>

 

</w:wordDocument>