我试图让我的 XPathNavigator 使用附加的代码工作(转到以前的属性名称“NAME”),但不知何故它不想移动。既不工作thisNavigator.MoveToFirstAttribute()
也不thisNavigator.MoveToAttribute("NAME", "");
工作...
我的 xml 内容看起来或多或少像这样
<PARAM NAME="Debug" HINT="Debug" TYPE="Int" VALUE="1" LEVEL="3"/>
我的代码:
switch (thisNavigator.Name)
{
case "VALUE":
{
thisNavigator.MoveToFirstAttribute();
thisNavigator.MoveToAttribute("NAME", "");
}
编辑 只是为了确保我刚刚检查过:
string x = thisNavigator.NamespaceURI;
它确实是空的,所以现在我更加困惑。
EDIT2 好的,我已经解决了这个问题,但还有很长的路要走。我必须回到父母,然后回到这个孩子,然后回到给定名称的属性。如果有人知道为什么它不想转到给定属性“向后”,我将不胜感激。这是我的代码:
thisNavigator.MoveToParent();
thisNavigator.MoveToFirstChild();
thisNavigator.MoveToAttribute("NAME", "" );