How to iterate recursively though a sharepoint list using webservices

sharepointweb services

in sharepoint webservices, I can use getListItems() to obtain the child elements of a list.

In a document library, sometimes the element is a folder.

"ows_FSObjType = 1"

Is there any way to ask SP for the child elements of this folder?

Querying with getListItems() using the folder ID gives me a SOAP Exception.

Edit:

I found that this webservice has got more method

Site Data Webservice

There is an "enumerate folder" method, which has got a "isFolder" property, but no method to recurse its contents.

Thank you, Sam. 🙂

Best Answer

On the GetListItems method, one of the optional parameters is an XMLNode called "QueryOptions". One of the elements you can put in that node is <Folder>.

So you should be able to pass in something like:

<QueryOptions>
    <Folder>/My/Path/Here</Folder>
</QueryOptions>

I may be off a bit syntatically (didn't try to build and run a query when making this post), but the general idea should be sound. You can see more details on this in the MSDN GetListItems Reference.

Related Topic