Here's some more sample code to help you, this shows how to get the Editable Fields from a Page's DocumentContent, how to get any widget on a page, and how to get any web part from a page template.
int DocumentWithEdtiableWebPart = 1221;
var PageItem = DocumentHelper.GetDocument(DocumentWithEdtiableWebPart, new TreeProvider());
// Example parsing edtiable text values
foreach (DictionaryEntry EditableWidgetNameKeyValue in PageItem.DocumentContent.EditableWebParts)
{
string key = ValidationHelper.GetString(EditableWidgetNameKeyValue.Key, ""); // myeditabletextregion;32c2488d-ae29-441c-aaae-fca979a5914e
string WebpartID = key.Split(';')[0]; //myeditabletextregion
string WebpartGUID = key.Split(';')[1]; //32c2488d-ae29-441c-aaae-fca979a5914e
string value = ValidationHelper.GetString(EditableWidgetNameKeyValue.Value, ""); //Test Content {^widget|(name)DateTime|(JsUseServerTime)False|(widget_displayname)Date+%26+time^}
// Note, could not figure out how to resolve the inline widgets, the macro context resolve macros didn't work.
}
// Example getting Widget values from Document
XmlDocument pagewidgets = new XmlDocument();
pagewidgets.LoadXml(string.IsNullOrWhiteSpace(PageItem.DocumentWebParts) ? "<page></page>" : PageItem.DocumentWebParts);
foreach (XmlNode widgetNode in pagewidgets.SelectNodes("//webpart"))
{
var theWidget = new WebPartInstance(widgetNode);
var testValue = theWidget.GetValue("visible");
}
// Example getting Page Template Web Parts from Page Template
int PageTemplateWithEditableTextID = 26832;
var PageTemplateWithEditableText = PageTemplateInfoProvider.GetPageTemplateInfo(PageTemplateWithEditableTextID);
string TemplateWebPartsStr = PageTemplateWithEditableText.WebParts;
XmlDocument TemplateWebParts = new XmlDocument();
TemplateWebParts.LoadXml(string.IsNullOrWhiteSpace(PageTemplateWithEditableText.WebParts) ? "<page></page>" : PageTemplateWithEditableText.WebParts);
foreach(XmlNode WebpartXml in TemplateWebParts.SelectNodes("//webpart"))
{
var theWebpart = new WebPartInstance(WebpartXml);
var testValue = theWebpart.GetValue("visible");
}
These use the namespaces
using CMS.PortalEngine;
using CMS.DocumentEngine;
using System.Xml;
using CMS.Helpers;
using CMS.Base;
using System.Collections;
using CMS.MacroEngine;
using CMS.Localization;