【问题标题】:How to Get the Title of a SharePoint List?如何获取 SharePoint 列表的标题?
【发布时间】:2012-07-26 16:31:42
【问题描述】:

我正在尝试使用 Web 服务从 SharePoint 检索列表。我遇到了this blog post 中描述的问题,即 GetList 方法显然希望传递列表的标题而不是列表的名称(即使参数称为“listName”)。我有列表的名称,但我不知道如何获取列表的标题。在哪里可以找到?

我在 Office 365 中使用 SharePoint,我相信是 2010。

【问题讨论】:

    标签: sharepoint sharepoint-2010 office365


    【解决方案1】:

    有点过头了,但试试这段代码。它只是一个示例代码,您可能希望将其塑造成您的逻辑。

    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);
    

    【讨论】:

      【解决方案2】:

      strListName:可以是列表名称,例如“文档”,也可以是列表的 GUID,带或不带花括号,格式如下:

      {318B9E8F-1EF4-4D49-9773-1BD2976772B6}

      you may find more info here - 以上信息摘自本文档

      【讨论】:

        猜你喜欢
        • 2019-03-27
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2019-12-11
        相关资源
        最近更新 更多