That was a short and vague description... Can you explain what you are trying to accomplish?
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...
Google is your friend, Dinesh.
You'll find many examples online on how to read from an XML file: http://csharp.net-tutorials.com/xml/reading-xml-with-the-xmlreader-class/
And examples on World on how to create a scheduled job: http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/8/Scheduled-jobs/Scheduled-jobs/
And how to create pages programatically (in the scheduled job): http://world.episerver.com/documentation/Items/Developers-Guide/EPiServer-CMS/7/Content/Pages-and-Blocks/How-To/Creating-a-Page-Programmatically/
That should get you started.
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?
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.
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: https://www.epinova.no/blog/arve-systad/dates/2014/11/episerver-commerce-essentials-4-import-from-external-systems/
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.
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);
I have Xml file. Format lilke given below
please suggest me how can i import these data into my episerver..