The Lists-WebService of Windows SharePoint has a method called GetList(). When using this method, you can retrieve the properties of a list, including its fields. GetList() returns an xml-structure, so you need to use the SelectNodes-method of the XmlNode-class to get the fields. Here’s a short snippet, how to extract the field-nodes from the result.

XmlNode xmlResult = WSLists.GetList({listname});

XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlResult.OwnerDocument.NameTable);
string strNamespace = xmlResult.GetNamespaceOfPrefix("");
nsmgr.AddNamespace("sp", strNamespace);  

XmlNodeList xmlFields = xmlResult.SelectNodes("//sp:Field", nsmgr);

foreach (XmlNode xmlField in xmlFields)
{
   … do anything with the field
}

You need the namespaces System.Xml and System.Xml.XPath in your code when using this code.

Advertisements