How to Get the Title of a SharePoint List?
我正在尝试使用 Web 服务从 SharePoint 检索列表。我遇到了这篇博文中描述的问题,即 GetList 方法显然希望传递列表的标题而不是列表的名称(即使参数称为"listName")。我有列表的名称,但我不知道如何获取列表的标题。我在哪里可以找到那个?
我在 Office 365 中使用 SharePoint,我相信它是 2010。
有点过头,但试试这个代码。它只是一个示例代码,您可能希望将其塑造成您的逻辑。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | string listName ="MyList"; Lists.Lists listSvc = new Lists.Lists(); listSvc.UseDefaultCredentials = true; XmlDocument xDoc = new XmlDocument(); xDoc.LoadXml(listSvc.GetListCollection().OuterXml); XmlNamespaceManager nsmgr = new XmlNamespaceManager(xDoc.NameTable); nsmgr.AddNamespace("A","http://schemas.microsoft.com/sharepoint/soap/"); XmlNode requiredList = xDoc.SelectSingleNode("//A:List[contains(@DefaultViewUrl,'" + listName +"')]", nsmgr); string listTitle = requiredList.Attributes["Title"].Value; XmlNode list = listSvc.GetList(listTitle); |
strListName:可以是列表名称,例如 "Documents",也可以是列表的 GUID,带或不带花括号,格式如下:
{318B9E8F-1EF4-4D49-9773-1BD2976772B6}
您可以在这里找到更多信息 - 以上信息是本文档的摘录