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
- parentnodeHtmlNode
- The 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
- nodeHtmlNode
Property Value
this[int]
Gets the node at the specified index.
public HtmlNode this[int index] { get; set; }Parameters
- indexint
Property Value
this[string]
Get node with tag name
public HtmlNode this[string nodeName] { get; }Parameters
- nodeNamestring
Property Value
Methods
Add(HtmlNode)
Add node to the collection
public void Add(HtmlNode node)Parameters
- nodeHtmlNode
Append(HtmlNode)
Add node to the end of the collection
public void Append(HtmlNode node)Parameters
- nodeHtmlNode
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
- itemHtmlNode
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
- namestring
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
- namestring
Returns
FindFirst(HtmlNodeCollection, string)
Get first instance of node in supplied collection
public static HtmlNode FindFirst(HtmlNodeCollection items, string name)Parameters
- itemsHtmlNodeCollection
- namestring
Returns
FindFirst(string)
Get first instance of node with name
public HtmlNode FindFirst(string name)Parameters
- namestring
Returns
GetNodeIndex(HtmlNode)
Get index of node
public int GetNodeIndex(HtmlNode node)Parameters
- nodeHtmlNode
Returns
IndexOf(HtmlNode)
Get index of node
public int IndexOf(HtmlNode item)Parameters
- itemHtmlNode
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
- nodeHtmlNode
Remove(HtmlNode)
Remove node
public bool Remove(HtmlNode item)Parameters
- itemHtmlNode
Returns
Remove(int)
Remove node at index
public bool Remove(int index)Parameters
- indexint
Returns
RemoveAt(int)
Remove HtmlNode at index
public void RemoveAt(int index)Parameters
- indexint
Replace(int, HtmlNode)
Replace node at index
public void Replace(int index, HtmlNode node)