I have been playing around with the Web Services provided by SharePoint and thought this code example might help someone else as it took me a bit to track down.
private ListService.Lists listService = new ListService.Lists();
private void LoadList(string listName) {
XmlDocument doc = new XmlDocument();
doc.LoadXml("<Document><Query/><ViewFields/><QueryOptions/></Document>");
XmlNode listQuery = doc.SelectSingleNode("//Query");
XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");
XmlNode node;
listService.UseDefaultCredentials = true;
listService.Url = "http://localhost/_vti_bin/Lists.asmx";
node = listService.GetListItems(listName, string.Empty, listQuery, listViewFields, "0", listQueryOptions, string.Empty);
XmlTextReader reader = new XmlTextReader(node.OuterXml, XmlNodeType.Element, null);
DataSet ds = new DataSet();
ds.ReadXml(reader);
DataTable table = ds.Tables["row"];
}
No comments yet... Be the first to leave a reply!