ICatalogManager3::ImportXML Method [C++]

Use this method to import an Extensible Markup Language (XML)-formatted file as catalog data.

Definition

[C++]

HRESULT ICatalogManager3::ImportXML(VARIANTvrXML,
  VARIANT_BOOLfUpdateOnly,
  VARIANT_BOOLfRunSynchronouslyVARIANT_BOOLfGenerateFullTextIndexes);

[Visual Basic]

Sub ImportXML(vrXML As Variant,
  Optional fUpdateOnly As Boolean,
  Optional fRunSynchronously As BooleanOptional fGenerateFullTextIndexes As Boolean)

Parameters

  • vrXML[C++]
    [in] A VARIANT that contains the XML file name or IStream object that is the target of the import.
  • vrXML[Visual Basic]
    A Variant that contains the XML file name or IStream object that is the target of the import.
  • fUpdateOnly[C++]
    [in, defaultvalue (0)] A VARIANT_BOOL that specifies whether to update an existing catalog or create a new one. A value of True indicates that if the system contains a catalog whose name is the same as the one specified in the strCatalogName parameter, it will be updated with the imported data. A value of False indicates to delete the catalog if it already exists and create a new one with the imported data.
  • fUpdateOnly[Visual Basic]
    A Boolean that specifies whether to update an existing catalog or create a new one. A value of True indicates that if the system contains a catalog whose name is the same as the one specified in the strCatalogName parameter, it will be updated with the imported data. A value of False indicates to delete the catalog if it already exists and create a new one with the imported data. The default is False.
  • fRunSynchronously [C++]
    [in, defaultvalue (0)] A VARIANT_BOOL that specifies whether the method should be run synchronously. A value of True indicates that the method will not return until the import is completed. A value of False indicates that the method will return immediately after spawning the import thread.
  • fRunSynchronously [Visual Basic]
    A Boolean that specifies whether the method should be run synchronously. A value of True indicates that the method will not return until the import is completed. A value of False indicates that the method will return immediately after spawning the import thread. The default is False.
  • fGenerateFullTextIndexes[C++]
    [in, defaultvalue (-1)] A VARIANT_BOOL that specifies whether the method should generate full text indexes. A value of True indicates that indexes should be generated. A value of False indicates that indexes should not be generated.
  • fGenerateFullTextIndexes[Visual Basic]
    A Boolean that specifies whether the method should generate full text indexes. A value of True indicates that indexes should be generated. A value of False indicates that indexes should not be generated. The default is True.

Return Values

[C++] This method returns an HRESULT indicating whether it completed successfully.

[Visual Basic] None.

Error Values

[C++] This method returns S_OK (0x00000000) to indicate success and either standard or custom COM HRESULT error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

[Visual Basic] This method sets the Number property of the global Err object to S_OK (&H00000000) to indicate success and to either standard or custom COM error values to indicate failure. For more information about standard COM errors, see Standard COM Errors.

The following table shows the custom COM errors that this method can return.

Name Value Description
E_CAT_CATMGR_NOT_INITIALIZED

[C++] 0x889800B

[Visual Basic] &H8898005

The CatalogManager object has not been initialized. The CatalogManager object should be initialized before calling this method.
E_CAT_FILE_OPEN_ERROR

[C++] 0x8898002

[Visual Basic] &H8898000

Unable to open the file. Check that the file exists and you have the necessary permissions on the file.
E_CAT_IMPORT_IN_PROGRESS

[C++] 0x8898002

[Visual Basic] &H8898005

This operation cannot be started because an import operation is currently in progress.
E_CAT_MSXML3_MISSING

[C++] 0x889800C

[Visual Basic] &H8898001

The Catalog import operation was unable to instantiate the XML parser. Please check that msxml3.dll is installed and registered on this machine. Refer to the Commerce Server installation documents for more information.
E_CAT_INVALID_XML error There has been an error. See the error message for more information.

[C++] Additional information may be available using the global Err object, which can be accessed using the API function GetErrorInfo. In particular, the GetDescription method of the IErrorInfo interface may return a text description of the error.

[Visual Basic] Additional information may be available using the global Err object. In particular, the Description property may contain a text description of the error.

Remarks

When performing a partial or delta import (when updating an existing catalog by importing new or changed catalog data), it is important that the catalog definition of the data being imported matches the definition of the existing catalog. For more information about the catalog definition, see Import Semantics.

This method runs in a separate thread. Prior to spawning the thread, it checks that the specified file can be opened and that there is not an existing ImportCSV or ImportXML method in progress. Once the new thread is spawned, this method returns immediately if the parameter fRunSynchronously is False, with no errors. Any errors that occurred while importing the catalog are logged to the Windows NT Event Log. Use the Windows Event Viewer to view the Windows NT Event Log.

Ee797667.caution(en-US,CS.20).gifCaution

  • If you call this method from Visual Basic Scripting Edition (VBScript) with the fRunSynchronously parameter set to False, VBScript will unload the object as soon as the script ends. If the script ends before the spawned thread finishes importing the catalog, it will be terminated prematurely and the catalog will not be imported successfully.

This method cannot be called in a transacted object. This method involves the creation, deletion, or updating of free text indexes. SQL Server does not allow these operations in a transaction.

If there is a temporary loss of the SQL Server connection, longer than two minutes, an import or export will be aborted. Other methods should work after the interruption.

The names of catalogs in the source file cannot begin with the character "#" or consist solely of spaces.

If a property existing in the catalog has one data type and the property of the same name existing in the import file has a different data type, the import will fail. For example, the catalog has a SKU property that is a String, and the XML file being imported has a SKU property that is an Integer. This will cause an error.

Additionally, if the minimum and maximum values of a property in the XML file do not match the minimum and maximum values of a property in the Product Catalog System and the property is used in one or more catalogs, then the import will fail; otherwise, the import will update the minimum and maximum values of that property.

[Visual Basic]

Setting the parameter fGenerateFullTextIndexes to False can significantly decrease import time when importing many catalogs from the same file. Use the ProductCatalog.RegenerateFreeTextSearchIndex method to create the indexes after the import has completed.

[C++]

Setting the parameter fGenerateFullTextIndexes to False can significantly decrease import time when importing many catalogs from the same file. Use the IProductCatalog3::RegenerateFreeTextSearchIndex method to create the indexes after the import has completed.

For more information about memory ownership issues related to COM property and method parameters, see Managing COM Parameter Memory.

[Visual Basic]

Example

myCatalogManager.ImportXML "c:\imports\ourcatalog.xml", TRUE

See Also

[C++]CatalogManager Object

[Visual Basic]CatalogManager Object

[C++]ICatalogManager3::ExportXML

[Visual Basic]CatalogManager.ExportXML

[C++]ICatalogManager3::ImportCSV

[Visual Basic]CatalogManager.ImportCSV

Copyright © 2005 Microsoft Corporation.
All rights reserved.