This documentation is archived and is not being maintained.

Lists.GetListContentTypes Method

Windows SharePoint Services 3
Returns a collection of content type definition schemas for all list content types on the given list.

Web Service: ListsWeb Reference: http://<Site>/_vti_bin/Lists.asmx

<SoapDocumentMethodAttribute("", RequestNamespace:="", ResponseNamespace:="", Use:=SoapBindingUse.Literal, ParameterStyle:=SoapParameterStyle.Wrapped)> _
Public Function GetListContentTypes ( _
	listName As String, _
	contentTypeId As String _
) As XmlNode
Dim instance As Lists
Dim listName As String
Dim contentTypeId As String
Dim returnValue As XmlNode

returnValue = instance.GetListContentTypes(listName, contentTypeId)



A string that represents the name of the list on which the content types are located.


A string that represents the content type ID of the content type.

Return Value

An XML fragment in the following form that can be assigned to a System.Xml.XmlNode object.
Each ContentType element in the XML fragment represents the schema definition for a site content type. The following example return value is edited for clarity.
<ContentTypes xmlns="">
      Group="Custom Content Types" 
      Description="Create a new document." 
    <Folder TargetName="Forms/NewContentType" />
    <DocumentTemplate TargetName="Forms/NewContentType/template.doc" />

Each content type definition is the same as would be returned by invoking the SchemaXml method.

The following example gets the content type definition schemas for the list content types on the specified list.

Imports System.Xml
Imports System.Web.Services.Protocols
Public Sub GetAllListContentTypes()
  Dim listService As New Web_Reference_Folder.Lists
  listService.Credentials = System.Net.CredentialCache.DefaultCredentials

  Dim listName As String = "listName"
  Dim contentTypeId As String = "0x0101"

  'Retrieve site content type data from Web service.
    Dim myNode As XmlNode = listService.GetListContentTypes(listName, contentTypeId)

    'Create XML document.
    Dim XmlDoc As New XmlDocument
    Dim d As XmlNode
    d = XmlDoc.CreateXmlDeclaration("1.0", "", "yes")

    'Move Web service data into XML document and save.
    Dim root As XmlNode = XmlDoc.CreateElement("ContentTypes")
    root.InnerXml = myNode.OuterXml

  Catch ex As SoapException
    MessageBox.Show("Message:" + ControlChars.Lf + ex.Message & _
      ControlChars.Lf & _
    "Detail:" + ControlChars.Lf + ex.Detail.InnerText & _
      ControlChars.Lf & _
    "StackTrace:" & ControlChars.Lf + ex.StackTrace)

  Catch ex As Exception

  End Try

End Sub