SPFieldLink.PITarget Property

Gets or sets the name of the processing instruction in an XML document of this content type, which can then be used to promote and demote property values.

Namespace:  Microsoft.SharePoint
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: Yes
Available in SharePoint Online

Syntax

'Declaration
Public Property PITarget As String
    Get
    Set
'Usage
Dim instance As SPFieldLink
Dim value As String

value = instance.PITarget

instance.PITarget = value
public string PITarget { get; set; }

Property Value

Type: System.String
A string that contains the processing instruction name.

Remarks

This property is meant to be used in combination with the PIAttribute property, to promote and demote document property values in processing instructions.

Property promotion refers to extracting document properties from a document and writing those property values to the appropriate columns in the document library where the document is stored. Property demotion refers to taking column values from the document library where a document is stored, and writing those column values into the document itself.

Important

To ensure that property promotion and demotion succeed, you must set the ReadOnly property of the SPFieldLink object to false.

The PITarget property specifies the document processing instruction. The PIAttribute property specifies an attribute of the processing instruction. Together, they form an address that the XML parser can use to locate a document property value.

For example, consider the following code.

SPFieldLink fieldRef = web.ContentTypes["MyXMLContentType"].FieldLinks["columnName"];
fieldRef.PITarget = "myPITarget";
fieldRef.PIAttribute = "myPIAttribute";
Dim fieldRef As SPFieldLink = web.ContentTypes("MyXMLContentType").FieldLinks("columnName")
fieldRef.PITarget = "myPITarget"
fieldRef.PIAttribute = "myPIAttribute"

The code sets the PITarget and PIAttribute properties to values that instruct the XML parser to examine the following processing instruction and attribute for a document property value.

<?myPITarget myPIAttribute="value"?>

Note that, rather than setting the properties programmatically, you can achieve the same result declaratively, by using the following Collaborative Application Markup Language (CAML) string.

<FieldRef ID="Guid" 
          Name="columnName"
          PITarget="myPITarget"
          PIAttribute="myPIAttribute" />

For more information, see Using Content Types to Specify XML Document Properties.

See Also

Reference

SPFieldLink Class

SPFieldLink Members

Microsoft.SharePoint Namespace

PIAttribute

Other Resources

Using Content Types to Specify XML Document Properties

XML Parser Processing

FieldRef Element (ContentType)

Fields and Field References