本文整理匯總了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);
}