获取列表项的 guid

发布于 2024-10-03 06:26:42 字数 98 浏览 0 评论 0原文

我有包含列表名称和项目名称的文本文件。我需要通过名称获取项目指南。如何? (在 splist 中不使用 foreach splistitem 项会导致文本文件很大并且循环会产生影响)

I have text file with List Name and item name. I need to get item guid by it's name. how? (not using foreach splistitem item in splist cause the text file is large and the loop is going to take a toll)

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

那请放手 2024-10-10 06:26:42

您可能有足够的信息来使用 SPWeb 函数 GetListItem,否则您需要尝试 SPWeb.SearchListItems。两者都不会那么快。

网络服务有一个不错的搜索功能,我已经使用过,例如:

  public static string GetPageId(string listName, string webPath, string pageTitle)
        {
            string pageId = "";
            IntranetLists.Lists lists = new IntranetLists.Lists();
            lists.UseDefaultCredentials = true;
            lists.Url = webPath + "/_vti_bin/lists.asmx";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<Document><Query><Where><Contains><FieldRef Name=\"Title\" /><Value Type=\"Text\">" + pageTitle + "</Value></Contains></Where></Query><ViewFields /><QueryOptions /></Document>");
            XmlNode listQuery = doc.SelectSingleNode("//Query");
            XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
            XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");

            Guid g = GetWebID(webPath);

            XmlNode items = lists.GetListItems(listName, string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, g.ToString());
            foreach (XmlNode listItem in SPCollection.XpathQuery(items, "//sp:listitems/rs:data/z:row"))
            {
                XmlAttribute id = listItem.Attributes["ows_Id"];
                if (id != null)
                {
                    pageId = id.Value;                    
                }

            }
            return pageId;            
        }

 public static XmlNodeList XpathQuery(XmlNode xmlToQuery, string xPathQuery)
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(xmlToQuery.OuterXml);
        XmlNamespaceManager mg = new XmlNamespaceManager(doc.NameTable);
        mg.AddNamespace("sp", "http://schemas.microsoft.com/sharepoint/soap/");
        mg.AddNamespace("z", "#RowsetSchema");                                   
        mg.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
        mg.AddNamespace("y", "http://schemas.microsoft.com/sharepoint/soap/ois");
        mg.AddNamespace("w", "http://schemas.microsoft.com/WebPart/v2");
        mg.AddNamespace("d", "http://schemas.microsoft.com/sharepoint/soap/directory");
        return doc.SelectNodes(xPathQuery, mg);
    }

You may have enough information to use the SPWeb function GetListItem, otherwise you will need to try SPWeb.SearchListItems. Neither of which is going to be all the fast either.

The web services have a decent search function that I have used such as:

  public static string GetPageId(string listName, string webPath, string pageTitle)
        {
            string pageId = "";
            IntranetLists.Lists lists = new IntranetLists.Lists();
            lists.UseDefaultCredentials = true;
            lists.Url = webPath + "/_vti_bin/lists.asmx";
            XmlDocument doc = new XmlDocument();
            doc.LoadXml("<Document><Query><Where><Contains><FieldRef Name=\"Title\" /><Value Type=\"Text\">" + pageTitle + "</Value></Contains></Where></Query><ViewFields /><QueryOptions /></Document>");
            XmlNode listQuery = doc.SelectSingleNode("//Query");
            XmlNode listViewFields = doc.SelectSingleNode("//ViewFields");
            XmlNode listQueryOptions = doc.SelectSingleNode("//QueryOptions");

            Guid g = GetWebID(webPath);

            XmlNode items = lists.GetListItems(listName, string.Empty, listQuery, listViewFields, string.Empty, listQueryOptions, g.ToString());
            foreach (XmlNode listItem in SPCollection.XpathQuery(items, "//sp:listitems/rs:data/z:row"))
            {
                XmlAttribute id = listItem.Attributes["ows_Id"];
                if (id != null)
                {
                    pageId = id.Value;                    
                }

            }
            return pageId;            
        }

 public static XmlNodeList XpathQuery(XmlNode xmlToQuery, string xPathQuery)
    {
        XmlDocument doc = new XmlDocument();
        doc.LoadXml(xmlToQuery.OuterXml);
        XmlNamespaceManager mg = new XmlNamespaceManager(doc.NameTable);
        mg.AddNamespace("sp", "http://schemas.microsoft.com/sharepoint/soap/");
        mg.AddNamespace("z", "#RowsetSchema");                                   
        mg.AddNamespace("rs", "urn:schemas-microsoft-com:rowset");
        mg.AddNamespace("y", "http://schemas.microsoft.com/sharepoint/soap/ois");
        mg.AddNamespace("w", "http://schemas.microsoft.com/WebPart/v2");
        mg.AddNamespace("d", "http://schemas.microsoft.com/sharepoint/soap/directory");
        return doc.SelectNodes(xPathQuery, mg);
    }
坐在坟头思考人生 2024-10-10 06:26:42

http://msdn.microsoft.com/en-us/library /microsoft.sharepoint.spsitedataquery.aspx 或 CamlQuery

SPListItemCollection items = web.Lists.GetItems(new SPQuery() { Query = "YOUR QUERY" });

http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.spsitedataquery.aspx or CamlQuery

SPListItemCollection items = web.Lists.GetItems(new SPQuery() { Query = "YOUR QUERY" });

提笔书几行 2024-10-10 06:26:42

进入列表设置页面。右键单击“标题、描述和导航”并复制 URL。将其粘贴到记事本中,然后复制字符串中“List=”后面的所有内容。这是列表的 URL 编码 GUID。您需要做的就是在这里对其进行解码 http://www.albionresearch.com/misc/urlencode.php

来源:http://weblogs.asp.net/jimjackson/archive/ 2008/02/11/从浏览器获取-a-sharepoint-list-guid-from-the-browser.aspx

这是为了手动获取某个列表的每个 GUID。

Go to the list settings page. Right click on "Title, description and navigation" and copy the URL. Paste that into notepad and copy everything after "List=" in the string. That's your URL Encoded GUID for the list. All you need to do is decode it here http://www.albionresearch.com/misc/urlencode.php

source: http://weblogs.asp.net/jimjackson/archive/2008/02/11/get-a-sharepoint-list-guid-from-the-browser.aspx

this is for manually getting each GUID of a certain list.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文