Table of Contents

Class HtmlNodeNavigator

Namespace
HtmlAgilityPack
Assembly
HtmlAgilityPack.dll

Represents an HTML navigator on an HTML document seen as a data store.

public class HtmlNodeNavigator : XPathNavigator
Inheritance
HtmlNodeNavigator

Constructors

HtmlNodeNavigator(Stream)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a stream.

public HtmlNodeNavigator(Stream stream)

Parameters

stream Stream

The input stream.

HtmlNodeNavigator(Stream, bool)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a stream.

public HtmlNodeNavigator(Stream stream, bool detectEncodingFromByteOrderMarks)

Parameters

stream Stream

The input stream.

detectEncodingFromByteOrderMarks bool

Indicates whether to look for byte order marks at the beginning of the stream.

HtmlNodeNavigator(Stream, Encoding)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a stream.

public HtmlNodeNavigator(Stream stream, Encoding encoding)

Parameters

stream Stream

The input stream.

encoding Encoding

The character encoding to use.

HtmlNodeNavigator(Stream, Encoding, bool)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a stream.

public HtmlNodeNavigator(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks)

Parameters

stream Stream

The input stream.

encoding Encoding

The character encoding to use.

detectEncodingFromByteOrderMarks bool

Indicates whether to look for byte order marks at the beginning of the stream.

HtmlNodeNavigator(Stream, Encoding, bool, int)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a stream.

public HtmlNodeNavigator(Stream stream, Encoding encoding, bool detectEncodingFromByteOrderMarks, int buffersize)

Parameters

stream Stream

The input stream.

encoding Encoding

The character encoding to use.

detectEncodingFromByteOrderMarks bool

Indicates whether to look for byte order marks at the beginning of the stream.

buffersize int

The minimum buffer size.

HtmlNodeNavigator(TextReader)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a TextReader.

public HtmlNodeNavigator(TextReader reader)

Parameters

reader TextReader

The TextReader used to feed the HTML data into the document.

HtmlNodeNavigator(string)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a file.

public HtmlNodeNavigator(string path)

Parameters

path string

The complete file path to be read.

HtmlNodeNavigator(string, bool)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a file.

public HtmlNodeNavigator(string path, bool detectEncodingFromByteOrderMarks)

Parameters

path string

The complete file path to be read.

detectEncodingFromByteOrderMarks bool

Indicates whether to look for byte order marks at the beginning of the file.

HtmlNodeNavigator(string, Encoding)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a file.

public HtmlNodeNavigator(string path, Encoding encoding)

Parameters

path string

The complete file path to be read.

encoding Encoding

The character encoding to use.

HtmlNodeNavigator(string, Encoding, bool)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a file.

public HtmlNodeNavigator(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks)

Parameters

path string

The complete file path to be read.

encoding Encoding

The character encoding to use.

detectEncodingFromByteOrderMarks bool

Indicates whether to look for byte order marks at the beginning of the file.

HtmlNodeNavigator(string, Encoding, bool, int)

Initializes a new instance of the HtmlNavigator and loads an HTML document from a file.

public HtmlNodeNavigator(string path, Encoding encoding, bool detectEncodingFromByteOrderMarks, int buffersize)

Parameters

path string

The complete file path to be read.

encoding Encoding

The character encoding to use.

detectEncodingFromByteOrderMarks bool

Indicates whether to look for byte order marks at the beginning of the file.

buffersize int

The minimum buffer size.

Properties

BaseURI

Gets the base URI for the current node. Always returns string.Empty in the case of HtmlNavigator implementation.

public override string BaseURI { get; }

Property Value

string

CurrentDocument

Gets the current HTML document.

public HtmlDocument CurrentDocument { get; }

Property Value

HtmlDocument

CurrentNode

Gets the current HTML node.

public HtmlNode CurrentNode { get; }

Property Value

HtmlNode

HasAttributes

Gets a value indicating whether the current node has child nodes.

public override bool HasAttributes { get; }

Property Value

bool

HasChildren

Gets a value indicating whether the current node has child nodes.

public override bool HasChildren { get; }

Property Value

bool

IsEmptyElement

Gets a value indicating whether the current node is an empty element.

public override bool IsEmptyElement { get; }

Property Value

bool

LocalName

Gets the name of the current HTML node without the namespace prefix.

public override string LocalName { get; }

Property Value

string

Name

Gets the qualified name of the current node.

public override string Name { get; }

Property Value

string

NameTable

Gets the System.Xml.XmlNameTable associated with this implementation.

public override XmlNameTable NameTable { get; }

Property Value

XmlNameTable

NamespaceURI

Gets the namespace URI (as defined in the W3C Namespace Specification) of the current node. Always returns string.Empty in the case of HtmlNavigator implementation.

public override string NamespaceURI { get; }

Property Value

string

NodeType

Gets the type of the current node.

public override XPathNodeType NodeType { get; }

Property Value

XPathNodeType

Prefix

Gets the prefix associated with the current node. Always returns string.Empty in the case of HtmlNavigator implementation.

public override string Prefix { get; }

Property Value

string

Value

Gets the text value of the current node.

public override string Value { get; }

Property Value

string

XmlLang

Gets the xml:lang scope for the current node. Always returns string.Empty in the case of HtmlNavigator implementation.

public override string XmlLang { get; }

Property Value

string

Methods

Clone()

Creates a new HtmlNavigator positioned at the same node as this HtmlNavigator.

public override XPathNavigator Clone()

Returns

XPathNavigator

A new HtmlNavigator object positioned at the same node as the original HtmlNavigator.

GetAttribute(string, string)

Gets the value of the HTML attribute with the specified LocalName and NamespaceURI.

public override string GetAttribute(string localName, string namespaceURI)

Parameters

localName string

The local name of the HTML attribute.

namespaceURI string

The namespace URI of the attribute. Unsupported with the HtmlNavigator implementation.

Returns

string

The value of the specified HTML attribute. String.Empty or null if a matching attribute is not found or if the navigator is not positioned on an element node.

GetNamespace(string)

Returns the value of the namespace node corresponding to the specified local name. Always returns string.Empty for the HtmlNavigator implementation.

public override string GetNamespace(string name)

Parameters

name string

The local name of the namespace node.

Returns

string

Always returns string.Empty for the HtmlNavigator implementation.

IsSamePosition(XPathNavigator)

Determines whether the current HtmlNavigator is at the same position as the specified HtmlNavigator.

public override bool IsSamePosition(XPathNavigator other)

Parameters

other XPathNavigator

The HtmlNavigator that you want to compare against.

Returns

bool

true if the two navigators have the same position, otherwise, false.

MoveTo(XPathNavigator)

Moves to the same position as the specified HtmlNavigator.

public override bool MoveTo(XPathNavigator other)

Parameters

other XPathNavigator

The HtmlNavigator positioned on the node that you want to move to.

Returns

bool

true if successful, otherwise false. If false, the position of the navigator is unchanged.

MoveToAttribute(string, string)

Moves to the HTML attribute with matching LocalName and NamespaceURI.

public override bool MoveToAttribute(string localName, string namespaceURI)

Parameters

localName string

The local name of the HTML attribute.

namespaceURI string

The namespace URI of the attribute. Unsupported with the HtmlNavigator implementation.

Returns

bool

true if the HTML attribute is found, otherwise, false. If false, the position of the navigator does not change.

MoveToFirst()

Moves to the first sibling of the current node.

public override bool MoveToFirst()

Returns

bool

true if the navigator is successful moving to the first sibling node, false if there is no first sibling or if the navigator is currently positioned on an attribute node.

MoveToFirstAttribute()

Moves to the first HTML attribute.

public override bool MoveToFirstAttribute()

Returns

bool

true if the navigator is successful moving to the first HTML attribute, otherwise, false.

MoveToFirstChild()

Moves to the first child of the current node.

public override bool MoveToFirstChild()

Returns

bool

true if there is a first child node, otherwise false.

MoveToFirstNamespace(XPathNamespaceScope)

Moves the XPathNavigator to the first namespace node of the current element. Always returns false for the HtmlNavigator implementation.

public override bool MoveToFirstNamespace(XPathNamespaceScope scope)

Parameters

scope XPathNamespaceScope

An XPathNamespaceScope value describing the namespace scope.

Returns

bool

Always returns false for the HtmlNavigator implementation.

MoveToId(string)

Moves to the node that has an attribute of type ID whose value matches the specified string.

public override bool MoveToId(string id)

Parameters

id string

A string representing the ID value of the node to which you want to move. This argument does not need to be atomized.

Returns

bool

true if the move was successful, otherwise false. If false, the position of the navigator is unchanged.

MoveToNamespace(string)

Moves the XPathNavigator to the namespace node with the specified local name. Always returns false for the HtmlNavigator implementation.

public override bool MoveToNamespace(string name)

Parameters

name string

The local name of the namespace node.

Returns

bool

Always returns false for the HtmlNavigator implementation.

MoveToNext()

Moves to the next sibling of the current node.

public override bool MoveToNext()

Returns

bool

true if the navigator is successful moving to the next sibling node, false if there are no more siblings or if the navigator is currently positioned on an attribute node. If false, the position of the navigator is unchanged.

MoveToNextAttribute()

Moves to the next HTML attribute.

public override bool MoveToNextAttribute()

Returns

bool

MoveToNextNamespace(XPathNamespaceScope)

Moves the XPathNavigator to the next namespace node. Always returns falsefor the HtmlNavigator implementation.

public override bool MoveToNextNamespace(XPathNamespaceScope scope)

Parameters

scope XPathNamespaceScope

An XPathNamespaceScope value describing the namespace scope.

Returns

bool

Always returns false for the HtmlNavigator implementation.

MoveToParent()

Moves to the parent of the current node.

public override bool MoveToParent()

Returns

bool

true if there is a parent node, otherwise false.

MoveToPrevious()

Moves to the previous sibling of the current node.

public override bool MoveToPrevious()

Returns

bool

true if the navigator is successful moving to the previous sibling node, false if there is no previous sibling or if the navigator is currently positioned on an attribute node.

MoveToRoot()

Moves to the root node to which the current node belongs.

public override void MoveToRoot()