Jaa


ImportXml Method (CatalogImportOptions, String)

For the latest version of Commerce Server 2007 Help, see the Microsoft Web site.

Imports an XML file.

Namespace:  Microsoft.CommerceServer.Catalog
Assembly:  Microsoft.CommerceServer.Catalog (in Microsoft.CommerceServer.Catalog.dll)

Syntax

'Declaration
Public Function ImportXml ( _
    catalogImportOptions As CatalogImportOptions, _
    fileName As String _
) As ImportProgress
'Usage
Dim instance As CatalogContext
Dim catalogImportOptions As CatalogImportOptions
Dim fileName As String
Dim returnValue As ImportProgress

returnValue = instance.ImportXml(catalogImportOptions, _
    fileName)
public ImportProgress ImportXml(
    CatalogImportOptions catalogImportOptions,
    string fileName
)
public:
ImportProgress^ ImportXml(
    CatalogImportOptions^ catalogImportOptions, 
    String^ fileName
)
public function ImportXml(
    catalogImportOptions : CatalogImportOptions, 
    fileName : String
) : ImportProgress

Parameters

Return Value

Type: Microsoft.CommerceServer.Catalog..::.ImportProgress
An ImportProgress class containing the progress of the import operation.

Exceptions

Exception Condition
ArgumentNullException

The fileName or the catalogImportOptions is null.

ArgumentNullException

The fileName is an empty string.

Remarks

Use this method to import an XML file as catalog data.

Importing an XML document with any identifying properties having their length in excess of 256 characters is allowed. However creating a product in such a catalog with the ProductId greater than 256 characters will throw an exception.

Examples

CatalogImportOptions catalogImportOptions = new CatalogImportOptions();
catalogImportOptions.Operation = ImportOperation.ValidateAndImport;
/*  Setting additional import options
  * Set the CSV list of catalogs to import
  catalogImportOptions.CatalogsToImport = "Catalgo1,Catalog2";
  catalogImportOptions.PropertiesToImport = "ListPrice";
  */
// The ImportXml returns an  ImportProgress object
// Use the Status property to determine the current status
ImportProgress importProgress = this.catalogContext.ImportXml(catalogImportOptions, fileName);
while (importProgress.Status == CatalogOperationsStatus.InProgress)
{
  System.Threading.Thread.Sleep(3000);
  // Call the refresh method to refresh the current status
  importProgress.Refresh();
}
Console.WriteLine(importProgress.EndDate);
// If the import operation failed
if (importProgress.Status == CatalogOperationsStatus.Failed ||
  importProgress.Status == CatalogOperationsStatus.CompletedWithErrors)
{
  // Use the Errors property to get the errors that occurred during import
  foreach (CatalogError error in importProgress.Errors)
  {
    Console.WriteLine(error.LineNumber);
    Console.WriteLine(error.Message);
  }
}

Permissions

See Also

Reference

CatalogContext Class

CatalogContext Members

ImportXml Overload

Microsoft.CommerceServer.Catalog Namespace