How easy is it to pull data from an Umbraco database to display in another Umbraco site or even another non-Umbraco asp.net site? The reason I ask is because I have a customer that wants to created a recruitment based website which I thought I could do in Umbraco fairly easily but the issue is that later on down the line they are going to need to use the data from this website on other websites that may or may not be Umbraco sites.
Taking a quick look at the database of the Umbraco website I can see that the data is not stored in a very straight forward manner (i.e. it uses GUID;s etc) therefore how easy is it going to be for an asp.net developer who has absolutely no experience or knowledge of Umbraco to pull the data (or possibly even write it) from the Umbraco website database?
I'd have thought that it would be easier to use your umbraco site to generate xml/rss, which you can then pull in to your new site and transform as required.
Reading the umbraco database directly from a 3rd app is evil (at least, I could never encourage that). I would recommend establishing a webservice which exposes the data in question to the world. Writing would a no go.
If writing a web service solution is out of scope, you could easily just write an xslt macro that renders your data as XML. That would enable you to consume that data in whatever way you'd like, and wouldn't limit you to the format provided by rss/atom.
If you just need the site XML content then you could write a macro that outputs the whole site XML and put it on a page. This would then work like a webservice. Your other site could call this "webservice" and parse the XML appropriately.
Post back if you need example code to pull the Umbraco XML. I'm sure it's out there on the net too.
This would be how I would expose content - you'd have to write something else if you wanted to expose templates, users, etc. though.
Wow, thanks for all the quick responses, Edward, I would only need to expose the content, how would I go about writing a macro to output the XML and also pulling it back in to another site?
Also what about pulling it into another Umbraco site?
If you want to sync multiple sites from one "master" site (that maybe served using umbraco) to some "client" sites (which do not necessarily run on umbraco), you should use umbraco api to send updates to the "client" sites whenever the content in question is updated (the client sites would need a webservice interface themselves).
You'll get a very simple xml file listing all nodes beneath the current. This can be extended as much as normal umbraco templates can be, and can be quite powerful
Thanks for the response, I tried creating your XSLT but it has a few errors, the first one was was the last </page> tag which I assume should be </pages> but then it throws an error on this line and I'm not sure how it should be:
Ok, I have got my XML output using Edwards suggestion, just wondered how I would make it more specific for example only list node that are a certain document type?
Thank you Dan, you're a legend, that is exactly what I need. At least now I can recommend using Umbraco for the solution because I know we can extract the data out easily for use on other websites. Don't mean to be cheeky but I don't suppose you know the answer to my other post about the Ultimate Picker because that is the only thing that is now holding up this project? Thanks again and thanks to everyone else who helped
Pulling data from Umbraco database - how easy?
How easy is it to pull data from an Umbraco database to display in another Umbraco site or even another non-Umbraco asp.net site? The reason I ask is because I have a customer that wants to created a recruitment based website which I thought I could do in Umbraco fairly easily but the issue is that later on down the line they are going to need to use the data from this website on other websites that may or may not be Umbraco sites.
Taking a quick look at the database of the Umbraco website I can see that the data is not stored in a very straight forward manner (i.e. it uses GUID;s etc) therefore how easy is it going to be for an asp.net developer who has absolutely no experience or knowledge of Umbraco to pull the data (or possibly even write it) from the Umbraco website database?
I'd have thought that it would be easier to use your umbraco site to generate xml/rss, which you can then pull in to your new site and transform as required.
Reading the umbraco database directly from a 3rd app is evil (at least, I could never encourage that). I would recommend establishing a webservice which exposes the data in question to the world. Writing would a no go.
+1 on a webservice oriented solution, only expose what's really necessary!
Cheers,
/Dirk
If writing a web service solution is out of scope, you could easily just write an xslt macro that renders your data as XML. That would enable you to consume that data in whatever way you'd like, and wouldn't limit you to the format provided by rss/atom.
If you just need the site XML content then you could write a macro that outputs the whole site XML and put it on a page. This would then work like a webservice. Your other site could call this "webservice" and parse the XML appropriately.
Post back if you need example code to pull the Umbraco XML. I'm sure it's out there on the net too.
This would be how I would expose content - you'd have to write something else if you wanted to expose templates, users, etc. though.
Cross posted! Great minds think alike!
Hi,
Wow, thanks for all the quick responses, Edward, I would only need to expose the content, how would I go about writing a macro to output the XML and also pulling it back in to another site?
Also what about pulling it into another Umbraco site?
If you want to sync multiple sites from one "master" site (that maybe served using umbraco) to some "client" sites (which do not necessarily run on umbraco), you should use umbraco api to send updates to the "client" sites whenever the content in question is updated (the client sites would need a webservice interface themselves).
It might not be the best idea to output the whole site for a couple of reasons, but xml is easy in umbraco as all content is xml anyhow.
if you just create a template with just
Then an xslt macro with something like
You'll get a very simple xml file listing all nodes beneath the current. This can be extended as much as normal umbraco templates can be, and can be quite powerful
Dan
Beat me to it @dandrayne!
I'd do it slightly differently but I guess it depends on how much of the content you need, etc:
I'd just do a copy of the node:
Put that in a macro and put it on a page (use @dandrayne's XML declaration above).
If you want to shift content between two Umbraco sites then maybe Umbraco consierge (pro) would be easier though?
In fact, what might also be useful would be to put this in an alternate template.
Create a template that has the XML declaration and a macro with the above XSLT. Call the template "myXml" for example
Then hit any page on your site and append "?altTemplate=myXml" to the URL. You should then get the XML representing that node and child nodes.
Hi Dan,
Thanks for the response, I tried creating your XSLT but it has a few errors, the first one was was the last </page> tag which I assume should be </pages> but then it throws an error on this line and I'm not sure how it should be:
20: >>> <name><xsl:value-of select="current()@nodeName" /></name> <<<
Ok, I have got my XML output using Edwards suggestion, just wondered how I would make it more specific for example only list node that are a certain document type?
Sorry just realised I have not got exactly what Edward suggested, I have used the following to list all the nodes XML:
but I want to list only node that are Job document type, I tried the following but it did not work, does anyone know where I am going wrong?
It's exactly the same as doing a "normal" template in that
Will get a list of all nodenames of type job, then you just build from there
Dan
Thank you Dan, you're a legend, that is exactly what I need. At least now I can recommend using Umbraco for the solution because I know we can extract the data out easily for use on other websites. Don't mean to be cheeky but I don't suppose you know the answer to my other post about the Ultimate Picker because that is the only thing that is now holding up this project? Thanks again and thanks to everyone else who helped
I'll take a look after lunch ^^
is working on a reply...
This forum is in read-only mode while we transition to the new forum.
You can continue this topic on the new forum by tapping the "Continue discussion" link below.