Word Hacks [Electronic resources]

Andrew Savikas

نسخه متنی -صفحه : 162/ 129
نمايش فراداده

Hack 92 Get the XML Toolbox

This free add-in from Microsoft lets you inspect the XML in a Word document while the document remains open, making it an essential tool for working with XML in Word.

The XML Toolbox is a Word plug-in that acts much like a web browser's View Source function. You can view an entire document's WordprocessingML representation without having to save and close it first, or you can view the underlying WordprocessingML for only a partial selection of a document. The Toolbox also has some other handy features for streamlining custom XML solution development in Word.

You can download and read an article about it from the following URL:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnofftalkl/odc_office01012004.asp

After you install the XML Toolbox, it appears as one of the choices when you select ViewToolbars. Figure 10-5 shows the toolbar open while viewing the Hello.xml file from [Hack #91] .

Figure 10-5. The XML Toolbox toolbar

Next, select XML ToolboxView XMLEntire Document (WordML) to open a new XML Viewer window, as shown in Figure 10-6. You can then save the XML as a separate file or copy it to the clipboard using the button at the bottom of the Viewer window.

Figure 10-6. The XML Viewer window

Figure 10-6 shows the XML generated by Word from the Hello.xml file in [Hack #91] . When you open a simple XML document, Word automatically inserts all the other information usually stored in a Word file.

When you choose to view just the current selection, Word adds enough additional XML to make the XML shown in the Viewer a standalone XML document. For example, if you select just a single word in a Word document, choose XML ToolboxView XMLCurrent Selection, and then click the "Save to File" button in the XML Viewer, the file created will be its own, fully functional Word document.

The XML Toolbox add-in requires .NET Programmability support. If you did not install the .NET Framework 1.1 prior to your Office 2003 installation, you may need to reinstall Office. The Toolbox download page offers more information, including instructions on determining if .NET support is installed on your system.

While the XML Toolbox is an indispensable learning aid, it leaves out some things from the XML, such as document metadata and spelling errors. When learning the ropes of WordprocessingML, you should also spend some time viewing Word documents saved as XML from other applications, such as a text editor or Internet Explorer.

Evan Lenz