I'm not 100% sure where you want to access the node from?
I would certainly go with option number 2, as long as you retrieve the ID in the correct way (whichever was you chose) it'll be from the cached XML file, so performance shouldn't be an issue, especially as you'd only need to access it once.
As a side note, I don't know but I assume "xmlDoc.Load" would load another version of the umbraco.config file into memory which wouldn't be good for performance.
uQuery will use the cached XML already in memory (the App_Data/umbraco.config file) so should be very quick.
web.config vs GlobalSettings.ContentXML for referencing a node
Hi there
Seeking some feedback on which is the preferred way and also which is the most time efficient.
I have a container within my site that I wish to "access" in a method. Obviously hard coding the node is not the solution, so I see 2 options:
Option 1: Add an application setting in the web.config to store the node ID
Pro: I would assume this is quicker
Con: Remembering to maintain the data between production and development sites where the node ID's are different.
Option 2: Use GlobalSettings.ContentXML and XPath to locate the node (there will only ever be one) and therefore access the NodeID.
Pro: Self contained and will automatically locate the node
Con: Possibly slower.
I look forward to some feedback.
Regards
Nigel
Hi Nigel,
I'm not 100% sure where you want to access the node from?
I would certainly go with option number 2, as long as you retrieve the ID in the correct way (whichever was you chose) it'll be from the cached XML file, so performance shouldn't be an issue, especially as you'd only need to access it once.
I would use 'GetNodesByXPath' in uQuery from uComponents here http://ucomponents.codeplex.com/wikipage?title=uQuery
Rich
Hi Rich
Thanks for the prompt response.
I have it working using the following code:
We do have the uComponents package installed on the site and I like the look of using the GetNodesByXPath method.
The bit that I haven't been able to figure out is how to use the method to return just a single node.
I tried the following but for now have commented it out... (we have a helper method to convert an object to a node, hence the ToNode() part)
Thanks again for your help.
Nigel
Hey Nigel,
I think it returns a nodeset so something like this
var nodes = uQuery.GetNodesByXPath("//regionsAndStores");
if (nodes.Count > 0)
{
var node = nodes[0];
int regionid = node.Id;
}
Rich
As a side note, I don't know but I assume "xmlDoc.Load" would load another version of the umbraco.config file into memory which wouldn't be good for performance.
uQuery will use the cached XML already in memory (the App_Data/umbraco.config file) so should be very quick.
Regards
Rich
is working on a reply...