Compartilhar via


XmlWebPart.Xml Property

Gets or sets the content for this Web Part.

Namespace:  Microsoft.SharePoint.WebPartPages
Assembly:  Microsoft.SharePoint (in Microsoft.SharePoint.dll)
Available in Sandboxed Solutions: No

Syntax

'Declaration
<RequiresDesignerPermissionAttribute> _
<WebPartStorageAttribute(Storage.Shared)> _
<ResourcesAttribute("", "Advanced", "Xml")> _
Public Property Xml As XmlElement
    Get
    Set
'Usage
Dim instance As XmlWebPart
Dim value As XmlElement

value = instance.Xml

instance.Xml = value
[RequiresDesignerPermissionAttribute]
[WebPartStorageAttribute(Storage.Shared)]
[ResourcesAttribute("", "Advanced", "Xml")]
public XmlElement Xml { get; set; }

Property Value

Type: System.Xml.XmlElement
System.Xml.XmlElement   Content for this Web Part.

Remarks

The Xml property is writable. For this Web Part, this content is always treated as XML. This is a shared property (such as AllUsers).

This property and XmlLink are similar to the embedded Contentand ContentLinkproperties of the Microsoft.SharePoint.WebPartPages.ContentEditorWebPart class. Web Part Pages first check to see whether XmlLink has a value. If it does, the Web Part Page uses the results of that link and ignores the Xml property. If XmlLink is not defined or is inaccessible, the Web Part Page uses the contents of the Xml property.

Examples

The following code example shows how to set this property.

//Create a new XML Web Part
XmlWebPart xmlWebPart = new XmlWebPart();

//Create an XmlElement to hold the value of the Xml property
XmlDocument xmlDoc = new XmlDocument();
XmlElement xmlElement = xmlDoc.CreateElement("MyElement");
xmlElement.InnerText = "<string>my xml</string>";

//Set the Xml property to the XmlElement
xmlWebPart.Xml = xmlElement;
'Create a new XML Web Part
Dim xmlWebPart As New XmlWebPart()

'Create an XmlElement to hold the value of the Xml property
Dim xmlDoc As New XmlDocument()
Dim xmlElement As XmlElement = xmlDoc.CreateElement("MyElement")
xmlElement.InnerText = "<string>my xml</string>"

'Set the Xml property to the XmlElement
xmlWebPart.Xml = xmlElement

See Also

Reference

XmlWebPart Class

XmlWebPart Members

Microsoft.SharePoint.WebPartPages Namespace