XmlNodeList list = null;
list = xmlResult.SelectNodes("/sitecore
/result
/item
[scWebsitePath='"+sitecoreContextItemPath+"'
and scTemplateId='"+templateId+"'
and scDateCreated > '"+publishedFrom+"'
and scDateCreated < '"+publishedTo+"']");
Above code returns me a list of all “validated” Nodes.
Is it also possible to have xPath check wheter a path ie. “xxx/yyy/zzz/” is part of a Node for example if the given path is “xxx/yyy/zzz/” and i want the items below that path to be returned:
- “xxx/yyy/zzz/abc/def/ghi” <- will be
valid - “xxx/yyy/zzz/abc/def/ghi/jkl” <- will
be valid - “xxx/yyy/zzz/aaa/aaa/zzz” <- won’t be
valid
I can access the node Path by doing this:
XmlNode thisScPath = node.SelectSingleNode("scPath");
if (thisScPath == null)
continue;
So i wonder if i can also do something like:
list = xmlResult.SelectNodes("/sitecore
/result
/item[scWebsitePath='"+sitecoreContextItemPath+"'
and scTemplateId='"+templateId+"'
and scDateCreated > '"+publishedFrom+"'
and scDateCreated < '"+publishedTo+"'
and scPath = '"+scPath+"/*']");
When deleting the invalid Nodes from the list this will save me alot of stress because of bad performance. I can eventually delete the invalid items using a c# string.IndexOf != -1 statement, but I’d like to do this with xPath if possible. Is this possible?
I think you want to check
or
in your XPath expression.
If you use the XPath 2.0 implementation from http://www.xqsharp.com/ then you could even use a regular expression and the matches function.