2013년 1월 31일 목요일

sharepoint lists.asmx get all folders


sharepoint lists.asmx get all folders
Getting all items in folders using the Lists.asmx Web Service


private string DocumentReturnString(DiCentralSharePointWs.Lists ListsWebService, string listName)
{
        System.Xml.XmlNode nodes;
        string value = string.Empty;
        try
        {
            XmlDocument xmlDoc = new XmlDocument();
            XmlNode query = xmlDoc.CreateNode(XmlNodeType.Element, "Query", "");
            XmlNode queryOptions = xmlDoc.CreateNode(XmlNodeType.Element, "QueryOptions", "");
            queryOptions.InnerXml = "<ViewAttributes Scope='RecursiveAll' />";

            nodes = ListsWebService.GetListItems(listName, null, null, null, null, queryOptions, null);            
        }
        catch
        {
            return string.Empty;
        }

        foreach (XmlNode outerNode in nodes.ChildNodes)
        {

            if (outerNode.NodeType.Equals(System.Xml.XmlNodeType.Element))
            {

                foreach (XmlNode node in outerNode.ChildNodes)
                {

                    if (node.NodeType.Equals(System.Xml.XmlNodeType.Element))
                    {
                        string fileName = node.Attributes.GetNamedItem("ows_FileLeafRef").Value.Split(new string[] { ";#" }, StringSplitOptions.None)[1].ToString(); ;
                        string filePath = node.Attributes.GetNamedItem("ows_FileRef").Value.Split(new string[] { ";#" }, StringSplitOptions.None)[1].ToString(); ;
                        string fullPath = HttpUtility.UrlPathEncode(txtSiteURL.Text + filePath);
                        value += "<a href=" + fullPath + ">" + fileName + "</a>" + "</br>";
                    }

                }

            }

        } 
        return value;
}

댓글 없음: