Microsoft has provided SharePoint Web services to work with
sites and sub sites. The URL for this site is: http://Server_Name/[sites/][Site_Name/]_vti_bin/Webs.asmx.
It provides five methods. The GetAllSubWebCollection method
returns the titles and URLs of all sites within the current site collection.
Here we use GetWebCollection() to get the titles and URLs of all sites directly
beneath the current site. Listing 1 shows the code to return all the sub sites
one level down.
Listing 1 – Get all the sub sites directly beneath
the current site
ws_webs.Webs ws = new ws_webs.Webs();
ws.Url = sSPSServer + @"/" +sSecondLevelSite + "/_vti_bin/Webs.asmx";
ws.Credentials =System.Net.CredentialCache.DefaultCredentials;
System.Xml.XmlNode nd = ws.GetWebCollection();
XmlNodeList ndlist = nd.ChildNodes;
foreach (XmlNode xGet in ndlist)
{
string sWebTitle = xGet.Attributes["Title"].Value;
string sOneSubSite =xGet.Attributes["Url"].Value;
}