Looking at the node api I dont see any way to get the XML directly (using C# here, not XSLT). With the Document api I can use myDoc.ToXML(), but when coverting to the faster node based access, I see no Node based equivalent.
For now, I'm simply loading the Umbraco.config file and querying it directly, but ideally I wouldnt need to load this document as it already exists in memory, right?
the Nodefactory should be the one you are looking for, see http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-the-nodefactory. The namespace has changed though, I think it's just umbraco.Nodefactory now. As the wiki entry says it's directly working on the in-memory representation of umbraco.config, so indeed no need to load it manually.
You might also want to check out LINQ2Umbraco (http://www.farmcode.org/post/2009/02/24/Linq-to-Umbraco.aspx) which also works on umbraco.config.
How to query Umbraco.Config from memory
Hi,
Looking at the node api I dont see any way to get the XML directly (using C# here, not XSLT). With the Document api I can use myDoc.ToXML(), but when coverting to the faster node based access, I see no Node based equivalent.
For now, I'm simply loading the Umbraco.config file and querying it directly, but ideally I wouldnt need to load this document as it already exists in memory, right?
Ok - any advice here would be much appreciated.
Cheers,
Andles.
Hi andles,
the Nodefactory should be the one you are looking for, see http://our.umbraco.org/wiki/reference/api-cheatsheet/working-with-the-nodefactory. The namespace has changed though, I think it's just umbraco.Nodefactory now. As the wiki entry says it's directly working on the in-memory representation of umbraco.config, so indeed no need to load it manually.
You might also want to check out LINQ2Umbraco (http://www.farmcode.org/post/2009/02/24/Linq-to-Umbraco.aspx) which also works on umbraco.config.
Yet another alternative is to use the new Razor implementation for providing dynamic data in your templates, Gareth Evans has just posted a series of blog posts about it's features: http://umbraco.com/follow-us/blog-archive/2011/2/23/umbraco-47-razor-feature-walkthrough-%E2%80%93-part-1
Hope that helps,
Sascha
Brilliant! That will work nicely thank you very much...thanks Sascha.
is working on a reply...