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
HtmlNodeThe base node of the collection
Properties
Count
Gets the number of elements actually contained in the list.
public int Count { get; }
Property Value
IsReadOnly
Is collection read only
public bool IsReadOnly { get; }
Property Value
this[HtmlNode]
Gets a given node from the list.
public int this[HtmlNode node] { get; }
Parameters
node
HtmlNode
Property Value
this[int]
Gets the node at the specified index.
public HtmlNode this[int index] { get; set; }
Parameters
index
int
Property Value
this[string]
Get node with tag name
public HtmlNode this[string nodeName] { get; }
Parameters
nodeName
string
Property Value
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
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
CopyTo(HtmlNode[], int)
Copy collection to array
public void CopyTo(HtmlNode[] array, int arrayIndex)
Parameters
Descendants()
Get all node descended from this collection
public IEnumerable<HtmlNode> Descendants()
Returns
Descendants(string)
Get all node descended from this collection with matching name
public IEnumerable<HtmlNode> Descendants(string name)
Parameters
name
string
Returns
Elements()
Gets all first generation elements in collection
public IEnumerable<HtmlNode> Elements()
Returns
Elements(string)
Gets all first generation elements matching name
public IEnumerable<HtmlNode> Elements(string name)
Parameters
name
string
Returns
FindFirst(HtmlNodeCollection, string)
Get first instance of node in supplied collection
public static HtmlNode FindFirst(HtmlNodeCollection items, string name)
Parameters
items
HtmlNodeCollectionname
string
Returns
FindFirst(string)
Get first instance of node with name
public HtmlNode FindFirst(string name)
Parameters
name
string
Returns
GetNodeIndex(HtmlNode)
Get index of node
public int GetNodeIndex(HtmlNode node)
Parameters
node
HtmlNode
Returns
IndexOf(HtmlNode)
Get index of node
public int IndexOf(HtmlNode item)
Parameters
item
HtmlNode
Returns
Insert(int, HtmlNode)
Insert node at index
public void Insert(int index, HtmlNode node)
Parameters
Nodes()
All first generation nodes in collection
public IEnumerable<HtmlNode> Nodes()
Returns
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
Remove(int)
Remove node at index
public bool Remove(int index)
Parameters
index
int
Returns
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)