How is it possible to query umbraco for a node based on it's node name? I am not trying to query from xslt, I am trying to send the query from a custom aspx page with C#. Should I query with Lucene?
you can use umbraco.content.Instance.XmlContent (XmlContent is of type XmlDocument) and then use a normal XPath query like //node[@nodeName='QUERYNODENAME'] so this would be the complete statement:
Bear in mind that whilst nodes on the same branch will have unique names, there may be many nodes with the same name in different parts of the content tree.
There seems to be quite a few requests to get nodes by name, so I thought I'd add a couple of methods to http://blog.hendyracher.co.uk/umbraco-helper-class/ to get a single node by name from a given parent node, and to get all nodes that match a particular name, incase unpublished nodes need to be queried.
Query for a specific node
Hi all,
How is it possible to query umbraco for a node based on it's node name? I am not trying to query from xslt, I am trying to send the query from a custom aspx page with C#. Should I query with Lucene?
Thanks in advance.
Hi,
you can use umbraco.content.Instance.XmlContent (XmlContent is of type XmlDocument) and then use a normal XPath query like //node[@nodeName='QUERYNODENAME'] so this would be the complete statement:
XmlNode node = umbraco.content.Instance.XmlContent.SelectSingleNode("//node[@nodeName='NAMETOQUERY']");
Hope this helps
Toby
Hi Yang,
Bear in mind that whilst nodes on the same branch will have unique names, there may be many nodes with the same name in different parts of the content tree.
There seems to be quite a few requests to get nodes by name, so I thought I'd add a couple of methods to http://blog.hendyracher.co.uk/umbraco-helper-class/ to get a single node by name from a given parent node, and to get all nodes that match a particular name, incase unpublished nodes need to be queried.
HTH,
Hendy
is working on a reply...