Webs.GetAllSubWebCollection method

Returns the titles and URLs of all sites within the current site collection.

Namespace:  WebSvcWebs
Assembly:  STSSOAP (in STSSOAP.dll)

Syntax

'Declaration
<SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/GetAllSubWebCollection", RequestNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    ResponseNamespace := "https://schemas.microsoft.com/sharepoint/soap/",  _
    Use := SoapBindingUse.Literal, ParameterStyle := SoapParameterStyle.Wrapped)> _
Public Function GetAllSubWebCollection As XmlNode
'Usage
Dim instance As Webs
Dim returnValue As XmlNode

returnValue = instance.GetAllSubWebCollection()
[SoapDocumentMethodAttribute("https://schemas.microsoft.com/sharepoint/soap/GetAllSubWebCollection", RequestNamespace = "https://schemas.microsoft.com/sharepoint/soap/", 
    ResponseNamespace = "https://schemas.microsoft.com/sharepoint/soap/", 
    Use = SoapBindingUse.Literal, ParameterStyle = SoapParameterStyle.Wrapped)]
public XmlNode GetAllSubWebCollection()

Return value

Type: System.Xml.XmlNode
An XML fragment in the following form that can be assigned to a System.Xml.XmlNode object.

<Webs xmlns="https://schemas.microsoft.com/sharepoint/soap/">
   <Web Title="Site1_Name" Url="http://Server_Name/sites/Site_Name" />
   <Web Title="Site2_Name" Url="http://Server_Name/sites/Site_Name/Subsite_1" />
   <Web Title="Site3_Name" Url="http://Server_Name/sites/Site_Name/Subsite_1/Subsite_2" />
   .
   .
   .
</Webs>

Examples

The following code example displays the titles of all sites within the current site collection. This example requires that a using (Visual C#) or Imports (Visual Basic) directive be included for the System.Xml namespace.

Dim websService As New Web_Reference_Folder_Name.Webs()
websService.Credentials = System.Net.CredentialCache.DefaultCredentials

Dim strMessage As String = ""

Dim myNode As XmlNode = websService.GetAllSubWebCollection()

Dim nodes As XmlNodeList = myNode.SelectNodes("*")

Dim node As XmlNode

For Each node In  nodes

    strMessage = strMessage + node.Attributes("Title").Value + ControlChars.Lf

Next node

MessageBox.Show(strMessage)
Web_Reference_Folder_Name.Webs websService = new Web_Reference_Folder_Name.Webs();
websService.Credentials= System.Net.CredentialCache.DefaultCredentials;

string strMessage = "";

XmlNode myNode = websService.GetAllSubWebCollection();

XmlNodeList nodes = myNode.SelectNodes("*");

foreach (XmlNode node in nodes)
{
    strMessage = strMessage + node.Attributes["Title"].Value + "\n";
}

MessageBox.Show(strMessage);

See also

Reference

Webs class

Webs members

WebSvcWebs namespace