Consume XML Feeds with Custom Contenttypes

Topics: Writing modules
Nov 4, 2012 at 11:29 AM

Hi,

I run into the following Problem:

 

I created an custom contenttype "Events". Now I need to consume an xml feed and parse this feed to the Event-Contenttype and display them together with the Events in the database.

 

I have no idea where I should start?

 

Thanks

Developer
Nov 4, 2012 at 11:57 AM

You need to create a module to handle that. http://docs.orchardproject.net/Documentation/Walkthrough-Writing-An-Orchard-Module

If you make a Migrations class then you can create the Event in there.

From that you need to then create a service, or something to pull in the XML feed.. Is it something that should run every so often? If yes you might want to look at Background processes in Orchard.

To create and even in Orchard you can do this... _orchardServices.ContentManager.Create("Event")

From there you can start mapping.

Hope that gives you some idea. The best thing is to hunt around the code base looking at the modules directory to see how other stuff is implemented.

Nick

Nov 4, 2012 at 5:22 PM

Thanks for the answer.

I'm right, that if I add these contentitem to the ContentManager that it gets persistent into the database? Thats the thing I don't want.

 

Benschi

Developer
Jan 2, 2013 at 2:35 PM

The Create method will persist the content item. The New method will simply instantiate a content item of the specified content type, not persist it. You could try and instantiate "Event" content items, build display shapes. and render these.