Take a look at Hendy's Umbraco Helper Class, there's a method called "GetNodesFromXpath", which will return a generic List of Node objects. Here's a snippet:
public static List<Node> GetNodesFromXpath(string xPath)
{
List<Node> nodes = new List<Node>();
XPathNavigator xPathNavigator = umbraco.content.Instance.XmlContent.CreateNavigator(); //get all umbraco xml
XPathNodeIterator xPathNodeIterator = xPathNavigator.Select(xPath); //TODO: check xpath string is valid
int id;
Node node;
while (xPathNodeIterator.MoveNext())
{
if (int.TryParse(xPathNodeIterator.Current.Evaluate("string(@id)").ToString(), out id)) //check id is a numberic
{
node = new Node(id);
if (node != null) { nodes.Add(node); }
}
}
return nodes;
}
This way you can use whatever XPath queries you like... and get back a .NET object!
Can we use xslt to get umbraco document of specific type having specific value of some specific property in .NET
can we search or find or query any specific node of some specific type and having some value in its specific property? in .NET code
e.g some thing like the following in .NET
$currentPage/ancestor::root/descendant-or-self::node[@nodeTypeAlias='I-Article' and data [@alias='isPressRelease'] = '1']/@id)
using any Nodes, Node , Document classes ?
Hi ayyaz
Yes that is possible. Have a look at the API cheatsheet http://our.umbraco.org/wiki/reference/api-cheatsheet/modifying-document-properties
/Jan
Hi ayyaz,
Take a look at Hendy's Umbraco Helper Class, there's a method called "GetNodesFromXpath", which will return a generic List of Node objects. Here's a snippet:
This way you can use whatever XPath queries you like... and get back a .NET object!
Cheers, Lee
is working on a reply...