我需要最有效的方法来从XmlNodeList中过滤出节点。我从dtSearch得到的是XmlNodeList。该列表包含在指定searchPhrase上找到的项目列表。我想过滤掉所有不属于我想要查看的网站的项目。关于结果所在网站的信息存储在结果的路径中,我可以使用以下命令访问它:
// Get a list of Item nodes
XmlNodeList list = xmlResult.SelectNodes("/sitecore/result/item");
foreach (System.Xml.XmlNode node in list)
{
XmlNode thisScPath = node.SelectSingleNode("scPath");
if (thisScPath == null)
continue;
}假设我想用一个包含字符串"xxy“的scPath过滤掉所有节点,是否可以在进入遍历列表中所有节点的foreach之前这样做?例如,我能用Linq做到这一点吗?
发布于 2010-11-03 17:21:41
您可以向XPath表达式添加谓词,例如
/sitecore/result/item[scPath!='xxy']将查找没有子节点"scPath“和值"xxy”的所有项目节点。
https://stackoverflow.com/questions/4085562
复制相似问题