Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

I am trying to retrieve lists from a sharepoint site. I know how to do it using web services. However, the requirement is that I need to use Xelement GetList and the output should have PropertiesXML properties. Can anyone help??

share|improve this question

1 Answer 1

Try this code snippet:

 private void GetSourceListCollection()
        {

//SharePointList is my custom business object with properties.
            List<SharePointList> sourceListColl = new List<SharePointList>();
            XmlNode listsNode = listsSvcProxy.GetListCollection();
            string xmlnamespace = @"http://schemas.microsoft.com/sharepoint/soap/";
            var listsElements = from lists in listNode.DescendantsAndSelf((XNamespace)xmlnamespace + "List")
                                    select lists;

                foreach (XElement listelement in listsElements)
                {
                    SharePointList list = new SharePointList();
                    list.id = listelement.Attribute("ID").Value;
                    list.title = listelement.Attribute("Title").Value;
                    sourceListColl.Add(list);                        
                }
       }
share|improve this answer

Your Answer

 
discard

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