In our application, we are using SharePoint wiki library loosely as a content management system. Through custom code, I retrieve the contents of the wiki library along with its properties.
var array = new List<object>();
MsOnlineClaimsHelper claimsHelper = new MsOnlineClaimsHelper("https://mysharepointsite.com", "myusername", "mypassword");
using (ClientContext context = new ClientContext("mylocation"))
{
context.ExecutingWebRequest += claimsHelper.clientContext_ExecutingWebRequest;
Web web = context.Web;
ListCollection lists = web.Lists;
List selectedList = lists.GetByTitle("mylistname");
CamlQuery query = CamlQuery.CreateAllItemsQuery();
ListItemCollection items = selectedList.GetItems(query);
context.Load(items);
context.ExecuteQuery();
foreach (ListItem listItem in items)
{
array.Add(new
{
sharepointid = listItem["ID"].ToString(),
wikicontent = Convert.ToString(listItem["WikiField"] as object),
});
}
}
return array;
The wikicontent comes back with the HTML, problem is, it doesnt have all of the style information associated with it. So the HTML does not look like how it looks in the wiki.
Content in Wiki
Content from retrieved HTML
The actual HTML that I get from the code above looks like
<div class="ExternalClass7A473DBC7A6C41109A4FC8978BF5BDD9">
<table id="layoutsTable" style="width:100%;">
<tbody>
<tr style="vertical-align:top;">
<td style="width:100%;">
<div class="ms-rte-layoutszone-outer" style="width:100%;">
<div class="ms-rte-layoutszone-inner" role="textbox" aria-autocomplete="both" aria-haspopup="true" aria-multiline="true">
<h1>This is a test page<br></h1>
<p><br></p>
<p>... and <span class="ms-rteFontSize-3">this </span>is a test <span class="ms-rteFontSize-6">content</span>, that has been <span class="ms-rteFontFace-7">formatted</span>. <br></p>
<br>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<span id="layoutsData" style="display:none;">false,false,1</span>
</div>
How do I get the proper formatting information?