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.

1 Answer 1


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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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