Export (0) Print
Expand All

Inserting XML Markup [Word 2003 XML Reference] --  Microsoft Office Word 2003 XML Software Development Kit

Office 2003

Inserting XML Markup [Word 2003 XML Reference]

Important  The information set out in this topic is presented exclusively for the benefit and use of individuals and organizations outside the United States and its territories or whose products were distributed by Microsoft before January 2010, when Microsoft removed an implementation of particular functionality related to custom XML from Word. This information may not be read or used by individuals or organizations in the United States or its territories whose products were licensed by Microsoft after January 10, 2010; those products will not behave the same as products licensed before that date or licenses for use outside the United States.

If you have an XML schema attached to your document, you can apply Extensible Markup Language (XML) tags around pieces of the content of the document. You can also remove XML tags without deleting content in the document.

Adding XML tags to a document

You can add XML tags to your document either directly in the document or by using the XML Structure task pane. In each case there are a few things to note:

  • To apply XML element tags to text in a Microsoft© Office Word 2003 document, the document must be attached to an XML schema. For more informaiton, see Attaching an XML Schema.
  • XML markup in Word must be always be well-formed. For example, the end of an XML tag must not overlap with the start of another. It is assumed you are familiar with the concept of well-formed XML. A complete description of what makes XML well-formed is beyond the scope of this topic.
  • After you select the content you to which you want to apply an element, Office Word 2003 makes available only elements defined by the XML schema associated with that selected content. For example, if you select content contained in a <customer> tag, then only elements defined within the <customer> element in the associated schema are available to choose from.

Adding XML tags directly in the document

Adding XML tags with the XML Structure task pane.

Removing XML tags from a document

You can remove XML tags from your document either directly in the document or by using the XML Structure task pane.

Removing an XML tag from within document's contents.

Removing an XML tag by using the XML Structure task pane.

Inserting data from an existing XML file

If you're starting with a new document, you can open any valid XML file in Office Word 2003 and then begin editing it. You can insert data from an existing Extensible Markup Language (XML) file into a Office Word 2003 document that already exists by using one of the two following methods.

Insert the contents of an existing XML file directly into the document.

Create a refreshable link to the contents of an external XML file within the document.

Understanding block-level tags and inline tags

In the main document window, a block-level tag is preceded and followed by a line break, and can contain block elements such as paragraphs and tables. An inline tag, on the other hand, flows inline with the text that precedes and follows it. There is nothing in an attached schema that makes an XML tag a block-level tag or an inline tag; this depends on the text selected when the user applies an XML tag from the XML Structure task pane to the selection. If the selection is a block element such as a paragraph or a table, then the tag becomes a block-level tag; otherwise, it becomes an inline tag. You can visually see the difference when XML tags are displayed: block tags appear with a clear background, and both their begin and end tags contain the tag's name. Inline tags appear with a light magenta background with their names only in the start tag. Inline tags' end tags do not have text in them.

It is important to note that an inline XML tag is inside a paragraph, whereas block-level tags contain paragraphs. For this reason, inline tags can only contain other XML items inside the tag, such as text, fields, and other forms of formatting. Therefore, if you try to insert a paragraph mark inside an inline XML element, Office Word 2003 correctly does not add the paragraph mark inside the XML element. Rather, Office Word 2003 moves the text that follows the paragraph mark outside the XML element. This is proper and expected behavior in order for Office Word 2003 to maintain well-formed XML. If you find yourself in a situation where you are trying to add a paragraph mark inside an inline XML element, you can instead use an XML block level tag. To do this, select the whole paragraph or the whole paragraphs that you want, including the paragraph marks for each paragraph. In the XML Structure pane, in the Choose an element to apply to your current selection list, click an XML tag. For more specific information on block-level and inline tags see Understanding Word's XML Markup.

More Information

For more information on the option settings used to configure the XML features in Word, see Understanding XML Options. For suggestions on troubleshooting problems that may occur while using these features, see Troubleshooting XML Documents in Word.

For additional information and examples that describe or demonstrate the end-to-end process of working with XML documents in Microsoft Office Word 2003, please see the following articles:

Editing XML Data with Microsoft Office Word 2003 and Microsoft Office Excel 2003
Creating and Applying an XML Resume Template in Microsoft Office Word 2003
Microsoft Office Word 2003 XML: Memo Styles Sample
XML and Microsoft Office Word 2003: Writing a Trip Report


©2004 Microsoft Corporation. All rights reserved. Permission to copy, display and distribute this document is available at: http://msdn.microsoft.com/library/en-us/odcXMLRef/html/odcXMLRefLegalNotice.asp
Show:
© 2014 Microsoft