Office XML Syntax

A fundamental concept in XML is that elements contain values or other elements. These elements are expressed as a pair of start and end tags, the forward slash (/) specifying an end tag. For example, a bicycle could be described using the following elements.


<Bicycle>
 <Model>2000</Model>
 <Speeds>3</Speeds>
 <Drive>Chain</Drive>
 <BuiltOn>1996.12.28T13:12-0800</BuiltOn>
</Bicycle>

In the example, Bicycle is the fundamental element, and it contains subelements that define the properties of the bicycle. A subelement can be required, but it can also be optional, meaning that the object it defines might not have that property. When an object has several of the same properties, some elements can be specified more than once, or up to a certain number of times, to define those properties. For example, the names of the colors in a flag might be defined as follows.


<Flag>
 <Color>Red</Color>
 <Color>White</Color>
 <Color>Blue</Color>
</Flag>

For more information about syntax, see the Extensible Markup Language (XML) Recommendation.

Boolean Values in Office XML Elements

Most Office XML elements that contain a Boolean value can be specified by a single tag instead of by start and end tags containing the value. By specifying a single element, the file size and complexity is reduced. For example, to specify case sensitivity, <x:CaseSensitive/> is used instead of <x:CaseSensitive>True</x:CaseSensitive>. The element is specified only when its content is not the default, further reducing the file size and complexity. In the previous example, the sort is not case-sensitive by default.

The protection XML elements cannot be specified in this way. For more information about protection, see the Security, Protection, and VBA Projects topic.

Namespaces

An XML namespace provides a method for creating unique XML element names, which are qualified by a namespace prefix and a single colon followed by the local name. The prefix, which is mapped to a Universal Resource Identifier (URI), specifies a namespace. The combination of the URI namespace and the local schema namespace produces names that are guaranteed to be universally unique. The following example shows the declarations for o and w global namespaces for a document, the default HTML namespace, and their URIs.


<html xmlns:o="urn:schemas.microsoft.com:office/office"
xmlns:w="urn:schemas.microsoft.com:office/word"
xmlns=urn:w3-org-ns:HTML>

To use namespace declarations, specify the namespace prefix and a single colon followed by the local name. The following example shows Microsoft Office and Microsoft Word elements in a Web page. The DocumentProperties, Created, OfficeDocumentSettings, and ReadOnlyRecommended elements come from the Office namespace, while the WordDocument and CurrentView elements come from the Word namespace. Note that the namespace prefix is used for both the start and end tags.


<xml>
<o:DocumentProperties>
 <o:Created>1997-11-18T00:10:21Z</o:Created>
</o:DocumentProperties>
<o:OfficeDocumentSettings>
 <o:ReadOnlyRecommended/>
</o:OfficeDocumentSettings>
<w:WordDocument>
 <w:CurrentView>Normal</w:CurrentView>
</w:WordDocument>
</xml>

The following namespace declarations are used in Office documents.

Prefix Namespace URI
Hypertext Markup Language (HTML), default urn:w3-org-ns:HTML
a Microsoft Access urn:schemas-microsoft-com:office/access
dt Data type uuid:C2F41010-65B3-11d1-A29F-00AA00C14882
o Microsoft Office urn:schemas-microsoft-com:office/office
p Microsoft PowerPoint urn:schemas-microsoft-com:office/powerpoint
rs XML-Data recordset urn:schemas-microsoft-com:rowset
rsSchema XML-Data rowset urn:RowsetSchema
s XML-Data schema uuid:BDC6E3F0-6DA3-11d1-A2A3-00AA00C14882
v Vector Markup Language (VML) urn:schemas-microsoft-com:vml
w Microsoft Word urn:schemas-microsoft-com:office/word
x Microsoft Excel urn:schemas-microsoft-com:office/excel