Table of Contents

Class HtmlNodeCollection

Namespace
HtmlAgilityPack
Assembly
HtmlAgilityPack.dll

Represents a combined list and collection of HTML nodes.

public class HtmlNodeCollection : IList<HtmlNode>, ICollection<HtmlNode>, IEnumerable<HtmlNode>, IEnumerable
Inheritance
HtmlNodeCollection
Implements
Inherited Members

Constructors

HtmlNodeCollection(HtmlNode)

Initialize the HtmlNodeCollection with the base parent node

public HtmlNodeCollection(HtmlNode parentnode)

Parameters

parentnode HtmlNode

The base node of the collection

Properties

Count

Gets the number of elements actually contained in the list.

public int Count { get; }

Property Value

int

IsReadOnly

Is collection read only

public bool IsReadOnly { get; }

Property Value

bool

this[HtmlNode]

Gets a given node from the list.

public int this[HtmlNode node] { get; }

Parameters

node HtmlNode

Property Value

int

this[int]

Gets the node at the specified index.

public HtmlNode this[int index] { get; set; }

Parameters

index int

Property Value

HtmlNode

this[string]

Get node with tag name

public HtmlNode this[string nodeName] { get; }

Parameters

nodeName string

Property Value

HtmlNode

Methods

Add(HtmlNode)

Add node to the collection

public void Add(HtmlNode node)

Parameters

node HtmlNode

Add(HtmlNode, bool)

Add node to the collection

public void Add(HtmlNode node, bool setParent)

Parameters

node HtmlNode
setParent bool

Append(HtmlNode)

Add node to the end of the collection

public void Append(HtmlNode node)

Parameters

node HtmlNode

Clear()

Clears out the collection of HtmlNodes. Removes each nodes reference to parentnode, nextnode and prevnode

public void Clear()

Contains(HtmlNode)

Gets existence of node in collection

public bool Contains(HtmlNode item)

Parameters

item HtmlNode

Returns

bool

CopyTo(HtmlNode[], int)

Copy collection to array

public void CopyTo(HtmlNode[] array, int arrayIndex)

Parameters

array HtmlNode[]
arrayIndex int

Descendants()

Get all node descended from this collection

public IEnumerable<HtmlNode> Descendants()

Returns

IEnumerable<HtmlNode>

Descendants(string)

Get all node descended from this collection with matching name

public IEnumerable<HtmlNode> Descendants(string name)

Parameters

name string

Returns

IEnumerable<HtmlNode>

Elements()

Gets all first generation elements in collection

public IEnumerable<HtmlNode> Elements()

Returns

IEnumerable<HtmlNode>

Elements(string)

Gets all first generation elements matching name

public IEnumerable<HtmlNode> Elements(string name)

Parameters

name string

Returns

IEnumerable<HtmlNode>

FindFirst(HtmlNodeCollection, string)

Get first instance of node in supplied collection

public static HtmlNode FindFirst(HtmlNodeCollection items, string name)

Parameters

items HtmlNodeCollection
name string

Returns

HtmlNode

FindFirst(string)

Get first instance of node with name

public HtmlNode FindFirst(string name)

Parameters

name string

Returns

HtmlNode

GetNodeIndex(HtmlNode)

Get index of node

public int GetNodeIndex(HtmlNode node)

Parameters

node HtmlNode

Returns

int

IndexOf(HtmlNode)

Get index of node

public int IndexOf(HtmlNode item)

Parameters

item HtmlNode

Returns

int

Insert(int, HtmlNode)

Insert node at index

public void Insert(int index, HtmlNode node)

Parameters

index int
node HtmlNode

Nodes()

All first generation nodes in collection

public IEnumerable<HtmlNode> Nodes()

Returns

IEnumerable<HtmlNode>

Prepend(HtmlNode)

Add node to the beginning of the collection

public void Prepend(HtmlNode node)

Parameters

node HtmlNode

Remove(HtmlNode)

Remove node

public bool Remove(HtmlNode item)

Parameters

item HtmlNode

Returns

bool

Remove(int)

Remove node at index

public bool Remove(int index)

Parameters

index int

Returns

bool

RemoveAt(int)

Remove HtmlNode at index

public void RemoveAt(int index)

Parameters

index int

Replace(int, HtmlNode)

Replace node at index

public void Replace(int index, HtmlNode node)

Parameters

index int
node HtmlNode