CSharpTest.Net
CreateNavigator Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.Html Namespace > XmlLightElement Class : CreateNavigator Method

Glossary Item Box

Returns a new System.Xml.XPath.XPathNavigator object.

Syntax

Visual Basic (Declaration) 
Public Function CreateNavigator() As XPathNavigator
C# 
public XPathNavigator CreateNavigator()

Example

Library/Library.Test/TestHtmlParser.cs

C#Copy Code
XPathNavigator nav = new HtmlLightDocument(document).CreateNavigator().SelectSingleNode("/html/body//p[@class='1']");
XPathNavigator pos = nav.Clone();
Assert.IsFalse(nav.MoveToPrevious());
Assert.IsTrue(nav.MoveToNext());
Assert.IsTrue(nav.MoveToPrevious());
Assert.IsTrue(nav.IsSamePosition(pos));

Assert.IsFalse(nav.MoveToFirstNamespace());
Assert.IsFalse(nav.MoveToNextNamespace());

Assert.IsTrue(Object.ReferenceEquals(nav.NameTable, pos.NameTable));
Assert.IsNotNull(nav.BaseURI);
Assert.AreEqual(nav.BaseURI, pos.BaseURI);

Assert.IsTrue(nav.MoveToId("one"));
Assert.AreEqual("body", nav.Name);
Assert.IsFalse(nav.MoveToId("none-exists"));
Assert.AreEqual("body", nav.Name);
VB.NETCopy Code
Dim nav As XPathNavigator = New HtmlLightDocument(document).CreateNavigator().SelectSingleNode("/html/body//p[@class='1']")
Dim pos As XPathNavigator = nav.Clone()
Assert.IsFalse(nav.MoveToPrevious())
Assert.IsTrue(nav.MoveToNext())
Assert.IsTrue(nav.MoveToPrevious())
Assert.IsTrue(nav.IsSamePosition(pos))

Assert.IsFalse(nav.MoveToFirstNamespace())
Assert.IsFalse(nav.MoveToNextNamespace())

Assert.IsTrue([Object].ReferenceEquals(nav.NameTable, pos.NameTable))
Assert.IsNotNull(nav.BaseURI)
Assert.AreEqual(nav.BaseURI, pos.BaseURI)

Assert.IsTrue(nav.MoveToId("one"))
Assert.AreEqual("body", nav.Name)
Assert.IsFalse(nav.MoveToId("none-exists"))
Assert.AreEqual("body", nav.Name)

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys