Code to Retrieve XML Data and Schema

This section shows how to retrieve a list of all defined profile schema names, and how to retrieve the schema corresponding to one of these schema names. Then, the Extensible Markup Language (XML) data and schema representation of a ProfileObject object is obtained.

  1. If not already connected, create a ProfileService object, oProfileService, and establish a connection to the Profile Store. For information about connecting to the Profile Store, see Code to Connect to the Profile Store.

  2. Create an empty XML Document Object Model (DOM) document.

    Dim xmlDoc
    Set xmlDoc = CreateObject("Microsoft.XMLDOM")
    
  3. Retrieve the XML string containing the list of all defined profile schema names and load it into the empty XML DOM document.

    xmlDoc.loadXML( oProfileService.GetProfileDefXML("", True) )
    
  4. Retrieve the collection of "ElementType" nodes that contain the names of the profile schemas.

    Dim xmlNodes
    Set xmlNodes = xmlDoc.getElementsByTagName("ElementType")
    
  5. Retrieve the first profile schema name.

    Dim sSchemaName
    sSchemaName = _
     xmlNodes.item(0).attributes.getNamedItem("name").nodeValue
    
  6. Retrieve the XML string for the schema corresponding to the first profile schema name.

    Dim sXMLSchema
    sXMLSchema = oProfileService.GetProfileDefXML(sSchemaName, False)
    
  7. Retrieve the schema and data representation for the profile, oUser1, created in Code to Create a New Profile.

    Dim sXMLSchemaAndData
    sXMLSchemaAndData = _
     oUser1.GetProfileXML(psRetrieveSchemaAndData, False)
    

Copyright © 2005 Microsoft Corporation.
All rights reserved.