本文整理汇总了C#中System.Xml.XPath.XPathNavigator.MoveToFirst方法的典型用法代码示例。如果您正苦于以下问题:C# XPathNavigator.MoveToFirst方法的具体用法?C# XPathNavigator.MoveToFirst怎么用?C# XPathNavigator.MoveToFirst使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XPath.XPathNavigator
的用法示例。
在下文中一共展示了XPathNavigator.MoveToFirst方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Navigation
public void Navigation ()
{
document.LoadXml ("<foo><bar /><baz /></foo>");
navigator = document.DocumentElement.CreateNavigator ();
Assert.AreEqual ("foo", navigator.Name, "#1");
Assert.IsTrue (navigator.MoveToFirstChild (), "#2");
Assert.AreEqual ("bar", navigator.Name, "#3");
Assert.IsTrue (navigator.MoveToNext (), "#4");
Assert.AreEqual ("baz", navigator.Name, "#5");
Assert.IsTrue (!navigator.MoveToNext (), "#6");
Assert.AreEqual ("baz", navigator.Name, "#7");
Assert.IsTrue (navigator.MoveToPrevious (), "#8");
Assert.AreEqual ("bar", navigator.Name, "#9");
Assert.IsTrue (!navigator.MoveToPrevious (), "#10");
Assert.IsTrue (navigator.MoveToParent (), "#11");
Assert.AreEqual ("foo", navigator.Name, "#12");
navigator.MoveToRoot ();
Assert.AreEqual (XPathNodeType.Root, navigator.NodeType, "#13");
Assert.IsTrue (!navigator.MoveToParent (), "#14");
Assert.AreEqual (XPathNodeType.Root, navigator.NodeType, "#15");
Assert.IsTrue (navigator.MoveToFirstChild (), "#16");
Assert.AreEqual ("foo", navigator.Name, "#17");
Assert.IsTrue (navigator.MoveToFirst (), "#18");
Assert.AreEqual ("foo", navigator.Name, "#19");
Assert.IsTrue (navigator.MoveToFirstChild (), "#20");
Assert.AreEqual ("bar", navigator.Name, "#21");
Assert.IsTrue (navigator.MoveToNext (), "#22");
Assert.AreEqual ("baz", navigator.Name, "#23");
Assert.IsTrue (navigator.MoveToFirst (), "#24");
Assert.AreEqual ("bar", navigator.Name, "#25");
}
示例2: Navigation
public void Navigation ()
{
document.LoadXml ("<foo><bar /><baz /></foo>");
navigator = document.DocumentElement.CreateNavigator ();
AssertEquals ("foo", navigator.Name);
Assert (navigator.MoveToFirstChild ());
AssertEquals ("bar", navigator.Name);
Assert (navigator.MoveToNext ());
AssertEquals ("baz", navigator.Name);
Assert (!navigator.MoveToNext ());
AssertEquals ("baz", navigator.Name);
Assert (navigator.MoveToPrevious ());
AssertEquals ("bar", navigator.Name);
Assert (!navigator.MoveToPrevious ());
Assert (navigator.MoveToParent ());
AssertEquals ("foo", navigator.Name);
navigator.MoveToRoot ();
AssertEquals (XPathNodeType.Root, navigator.NodeType);
Assert (!navigator.MoveToParent ());
AssertEquals (XPathNodeType.Root, navigator.NodeType);
Assert (navigator.MoveToFirstChild ());
AssertEquals ("foo", navigator.Name);
Assert (navigator.MoveToFirst ());
AssertEquals ("foo", navigator.Name);
Assert (navigator.MoveToFirstChild ());
AssertEquals ("bar", navigator.Name);
Assert (navigator.MoveToNext ());
AssertEquals ("baz", navigator.Name);
Assert (navigator.MoveToFirst ());
AssertEquals ("bar", navigator.Name);
}