DocumentVariable Class

Single Document Variable.When the object is serialized out as xml, its qualified name is w:docVar.

Inheritance Hierarchy

System.Object
  DocumentFormat.OpenXml.OpenXmlElement
    DocumentFormat.OpenXml.OpenXmlLeafElement
      DocumentFormat.OpenXml.Wordprocessing.DocumentVariable

Namespace:  DocumentFormat.OpenXml.Wordprocessing
Assembly:  DocumentFormat.OpenXml (in DocumentFormat.OpenXml.dll)

Syntax

'Declaration
Public Class DocumentVariable _
    Inherits OpenXmlLeafElement
'Usage
Dim instance As DocumentVariable
public class DocumentVariable : OpenXmlLeafElement

Remarks

[ISO/IEC 29500-1 1st Edition]

17.15.1.31 docVar (Single Document Variable)

This element specifies the parameters of a single document variable. A document variable is a storage location for arbitrary customer data in name/value pairs that is persisted in a given WordprocessingML document. Specifically, this element specifies through its name and val attributes the name and value pair for a given document variable.

[Note: This mechanism is maintained for legacy compatibility only, and should be avoided in favor of the custom XML data support defined in ISO/IEC 29500. end note]

[Example: Consider the following WordprocessingML fragment specifying a document variablenamed example and containing the value example value:

<w:docVars>
  <w:docVar w:name="example" w:val="example value" />
</w:docVars>

The docVar element defines a single document variable, named example using the name attribute, and assigned the value example value through the val attribute. end example]

Parent Elements

docVars (§17.15.1.32)

Attributes

Description

name (Document Variable Name)

Specifies the name of the parent document variable.

[Example: Consider the following WordprocessingML fragment specifying a document variable:

<w:docVars>
  <w:docVar w:name="example name" w:val="example value" />
</w:docVars>

The name attribute specifies that the name of the document variable is example name. end example]

The possible values for this attribute are defined by the ST_String simple type (§22.9.2.13).

val (Document Variable Value)

Specifies the value of the parent document variable.

[Example: Consider the following WordprocessingML fragment specifying a document variable:

<w:docVars>
  <w:docVar w:name="example name" w:val="Tristan Davis" />
</w:docVars>

The val attribute specifies that the value of the document variable is Tristan Davis. end example]

The possible values for this attribute are defined by the ST_String simple type (§22.9.2.13).

[Note: The W3C XML Schema definition of this element’s content model (CT_DocVar) is located in §A.1. end note]

© ISO/IEC29500: 2008.

Thread Safety

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.

See Also

Reference

DocumentVariable Members

DocumentFormat.OpenXml.Wordprocessing Namespace