Freigeben über


Using the SharePoint 2010 Client OM with Open XML – Extract Contents of a Wiki Page

This is a clipboard friendly version of example #6, Extract Contents of a Wiki Page, from Using the SharePoint 2010 Managed Client Object Model with Open XML.

This blog is inactive.
New blog: EricWhite.com/blog

Blog TOC

using System;
using System.Xml.Linq;
using Microsoft.SharePoint.Client;

class RetrieveListItems
{
static void Main()
{
ClientContext clientContext = new ClientContext("https://intranet.contoso.com");
List oList = clientContext.Web.Lists.GetByTitle("Eric's Wiki");
CamlQuery camlQuery = new CamlQuery();
camlQuery.ViewXml = @"<View/>";
ListItemCollection listItems = oList.GetItems(camlQuery);
clientContext.Load(
listItems,
items => items.Include(
item => item["FileRef"],
item => item["WikiField"]));
clientContext.ExecuteQuery();
foreach (ListItem oListItem in listItems)
{
Console.WriteLine("FileRef: {0}", oListItem["FileRef"]);
XElement e = XElement.Parse((string)oListItem["WikiField"]);
Console.WriteLine(e);
Console.WriteLine("====================================");
}
}
}