我正在尝试获取选定“Xpath 位置”中的所有元素并将它们添加到组合框/下拉列表中。
我尝试使用 Xpath 查询选择所有这些元素: /@* 和 XpathNodeIterator 中的 Select 方法。
问题是它返回一个不向前移动的迭代器,实际上,它说它没有子节点,并且不允许我将迭代器转换为 xmlElement 或节点,以便我至少可以在它们内部进行搜索。
这是代码:
while (anIterator.MoveNext())
{
//im trying to select all nodes of selected path which and return them to an iterator
secondIterator = anIterator.Current.Select("/@*");
while (secondIterator.MoveNext())
{
aNode = new Nodes();
aNode.Name = anIterator.Current.MoveToFirstChild().ToString();
nodeList.Add(aNode);
}
nodeList.Add(aNode);
}
获取当前节点中所有元素的任何解决方案?