I have a Custom Webpart deployed in the Site, to which I need to retrieve the XML definition programmatically using Client side object model, can anybody help?
EDIT: I used the following code.
string strSiteUrl = SiteUrl_txt.Text; using (ClientContext cContext = new ClientContext(strSiteUrl)) { //open Web Web oWeb = cContext.Web; cContext.Load(oWeb); File page = oWeb.GetFileByServerRelativeUrl("MySiteUrl"); LimitedWebPartManager limitedWebPartManager = page.GetLimitedWebPartManager(PersonalizationScope.Shared); cContext.Load(limitedWebPartManager, wps => wps.WebParts.Include(wp => wp.WebPart.Properties, wp => wp.WebPart.Title, wp => wp.WebPart.TitleUrl)); cContext.ExecuteQuery(); foreach (WebPartDefinition wp in limitedWebPartManager.WebParts) { if (wp.WebPart.Properties.FieldValues.ContainsKey("UniqueValue")) { // Here I need to extract the XML definition, but not sure what should I // add here so that I could get the entire XML definition, like the one // we get when we export the webpart as XML in webpart gallery mannually. } }