当前位置: 首页>>代码示例>>C#>>正文


C# XPathNavigator.MoveToFirst方法代码示例

本文整理汇总了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");
		}
开发者ID:Profit0004,项目名称:mono,代码行数:32,代码来源:XPathNavigatorTests.cs

示例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);
		}
开发者ID:jjenki11,项目名称:blaze-chem-rendering,代码行数:32,代码来源:XPathNavigatorTests.cs


注:本文中的System.Xml.XPath.XPathNavigator.MoveToFirst方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。