Try our conversational search powered by Generative AI!

Import XML Data To EpiServer


I have Xml file. Format lilke given below







please suggest me how can i import these data into my episerver..

Sep 29, 2015 8:39

That was a short and vague description... Can you explain what you are trying to accomplish?

Sep 29, 2015 8:45

One simple approach would be to use a ScheduledJob.

Create an XMLReader or deserialize the xml and loop the contents.

Then use the IContentRepository service to save the data into EPiServer.

Ps. Will not send code...

Edited, Sep 29, 2015 8:53

Google is your friend, Dinesh. 

You'll find many examples online on how to read from an XML file:

And examples on World on how to create a scheduled job:

And how to create pages programatically (in the scheduled job):

That should get you started.

Sep 29, 2015 9:39

Hi All,

Thanks for your prompt replies. Actually my requirement is i need to import an XML file data to episerver project. I know how to import XML data to sqlserver using csharp coding but i don't know how to mind columns values in episerver page type columns to the XML columns thats why i posted a question here. Let me explain my requirement once again

1) I have an XML file with lot of products info

2) I have a page type " Products" with some custom fields on episerver

3) How can i set the value of product category,product title fields on episerver programmatically?


Sep 30, 2015 7:50

Hi again Dinesh, 

It is not recommended to access the database directly and set the property values.

The database in itself has a rather complex relation between pages, its properties, culture specific values and versioning and this is handled by EPiServers APIs.

You need a way to match your xml-data to the content inside EPiServer. What are your identifiers?

1. Use IContentRepository.Load() method or other means to load the matching instance of the page type "Product" that is already stored.
    (This is probably going to be the tricky step, since I'm guessing there is no clean relation between your xml and the EPiServer data)

2. Then get a writeable version by calling page.CreateWriteableClone();

3. Set the properties on it.

4. Then use IContentRepository.Save() to save it back with the modified properties.

Sep 30, 2015 9:20

Are you trying to import to a Commerce site or do you a product page type in your cms solution?

If you are working on a CMS site, then do as Arild and Sven-Erik writes. You should not push data straight to the database, use the API.

If you are working with a Commerce site, you should use the file import in the commerce manager. There are some good tips here:

Sep 30, 2015 11:03


This looks not like a Commerce data file (either catalog or BusinessFoundation object).

It depends on what you want to achieve, but basically you can read the data from the XML file, then use IContentRepository to create/update the contents you want. Yes, we highly recommend to not manipulate databases directly. 

An example:

var contentRepo = ServiceLocator.Current.GetInstance<IContentRepository>();
var product = contentRepo.GetDefault<ProductContent>(parentLink); //parentLink is the ContentReference of the Category this product will belong to

product.Code = ...//value read from xml

product.Name = ...//value read from xml


contentRepo.Save(product, SaveAction.Publish, AccessLevel.None);



Sep 30, 2015 11:39
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.