SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to insert summary links into a custom content type.

PublishingPage newPage = publishingWeb.GetPublishingPages().Add(filename, layout);
                newPage.Title = page.NewPage.Title;

            // Update the fields on the new page
            SPFile file = currentWeb.GetFile(newPage.Url);
            SPListItem newPageItem = file.Item;
            newPageItem["Contact Info"] = page.NewPage.ContactInfo;                
            newPageItem["Summary Links"] = resolveSummaryLinks(page.NewPage.SummaryLinks); 

my "resolveSummaryLinks" code just creates a "SummaryLinkCollection" and returns that. However; the new page doesn't have any value for the "Summary Links" field. How should I be populating this field?

Thanks for any help.

share|improve this question

I did manage to figure it out. My collection needs to be serialized to a string THEN the xml declaration that is created needs to be removed.

SummaryLinkCollection collection = new SummaryLinkCollection();
//Other code to populate the collection
MemoryStream stream = new MemoryStream();
XmlWriter writer = XmlWriter.Create(stream);
string x = string.Empty;
x = Encoding.UTF8.GetString(stream.ToArray());
string y= x.Replace("<?xml version=\"1.0\" encoding=\"utf-8\"?>", "");
return y;

The removal of the xml declaration was very important, if not done, then trying to add the value would raise an exception that the xml declaration was unexpected.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.