Advanced Customization > Services and Infrastructure Customization > Import Export Framework > How to Write an IX Application > Use Importer to import object from XML files
  
Use Importer to import object from XML files
After you create an instance of the class Importer (importer) you can use it to import objects from XML files. If you have more than one XML files to import, you have to give IxbDocument-s that created from XML files to the importer one by one.
As mentioned above, the Import Application server must call two methods to do the import:
importer.doImport(IxbDocument doc);

importer.finalizeImport();
doImport (doc) : This method doesn’t really import the object, but inserts the XML document that represents the object in to a list to be imported later. After all XML documents representing all the imported objects are inserted in the import list, the real import process starts with the call to finalizeImport().
finalizeImport(): The import process is actually performed in this method. It will call to:
doCheckConflicts() - check conflicts for imported objects.
doRealImport () - do the real import for the list of objects by calling importElement (IxbElement doc) for each XML document representing each object in the list.
ImportElement(...) calls importElements(...) : In the method importElements(…) the import handler for a particular type of the object is created by calling getImportHandler(tag).
The method getImportHandler(…) finds the appropriate handler for the importing object as follows.
1. Try to get an import handler by using the DTD string in the <dtd> tag of the XML file of the imported object.
2. If the handler is null, try again using current DTD in the importer. This current DTD is calculated using version of the current Windchill. For Windchill Release 10.X it is standardX20.dtd.
After getting the handler for the element, the importElements(…) calls the following methods:
handler.importElements(…) to do the import task.

handler.outputLog(…) to send log to user.
All handlers for non-versioned objects (for example ReportTemplate ... ) extend the class ClassExporterImporterTemplate, all handlers for link objects (for example, PartUsageLink...) extend the class ExpImpForLinkObject, and and all handlers for versioned objects (for example Parts, Documents, EPMDocuments ...) extend the class ExpImpForVersionedObject.
* 
Handlers for non-versioned objects act like the previous versions.
If the real handler doesn’t implement the method importElements(…), then the call invokes the default method importElements(…) of the class ClassExporterImporterTemplate. In this class, the importElement(…) method calls to findAmongExistingObjects (elements, importer);.
If it finds that the object in the XML file currently exists in the database, it will not import the object. Otherwise, it will call the following methods:
createObjects ( elements, importer);
importObjectsAttributes (elements, importer);
storeObjects (elements, importer);
importObjectsAttributesAfterStore (elements, importer);
finalizeImprtObjects(isNewObject, elements, importer);
Some of these methods should be implemented in the handler, and it is how and when the real handler comes to do its job.
* 
Handlers for versioned objects act different.
If the real handler doesn’t implement the method importElements(…), then the call invokes the default method importElements(…) of the class ExpImpForVersionedObject. In this class, despite the object in the XML file exists in the database or not, the importElements(…) method always calls to:
createObject (elements, importer);
importObjectsAttributes (elements,
importer);
storeObjects (List<ElementObjectPair> pairs, importer);
importObjectsAttributesAfterStore (List<ElementObjectPair> pairs,
importer);
Then, the Import Application can do a clean-up, and send messages to the client. The import process is finished.