Table of Contents

Class HtmlAttributeCollection

Namespace
HtmlAgilityPack
Assembly
HtmlAgilityPack.dll

Represents a combined list and collection of HTML nodes.

public class HtmlAttributeCollection : IList<HtmlAttribute>, ICollection<HtmlAttribute>, IEnumerable<HtmlAttribute>, IEnumerable
Inheritance
HtmlAttributeCollection
Implements
Inherited Members

Properties

Count

Gets the number of elements actually contained in the list.

public int Count { get; }

Property Value

int

IsReadOnly

Gets readonly status of colelction

public bool IsReadOnly { get; }

Property Value

bool

this[int]

Gets the attribute at the specified index.

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

Parameters

index int

Property Value

HtmlAttribute

this[string]

Gets a given attribute from the list using its name.

public HtmlAttribute this[string name] { get; set; }

Parameters

name string

Property Value

HtmlAttribute

Methods

Add(HtmlAttribute)

Adds supplied item to collection

public void Add(HtmlAttribute item)

Parameters

item HtmlAttribute

Add(string, string)

Adds a new attribute to the collection with the given values

public void Add(string name, string value)

Parameters

name string
value string

AddRange(Dictionary<string, string>)

Adds a range supplied items to collection using a dictionary.

public void AddRange(Dictionary<string, string> items)

Parameters

items Dictionary<string, string>

A Dictionary<string,string> of items to append to this.

AddRange(IEnumerable<HtmlAttribute>)

Adds a range supplied items to collection.

public void AddRange(IEnumerable<HtmlAttribute> items)

Parameters

items IEnumerable<HtmlAttribute>

An IEnumerable<HtmlAttribute> of items to append to this.

Append(HtmlAttribute)

Inserts the specified attribute as the last attribute in the collection.

public HtmlAttribute Append(HtmlAttribute newAttribute)

Parameters

newAttribute HtmlAttribute

The attribute to insert. May not be null.

Returns

HtmlAttribute

The appended attribute.

Append(string)

Creates and inserts a new attribute as the last attribute in the collection.

public HtmlAttribute Append(string name)

Parameters

name string

The name of the attribute to insert.

Returns

HtmlAttribute

The appended attribute.

Append(string, string)

Creates and inserts a new attribute as the last attribute in the collection.

public HtmlAttribute Append(string name, string value)

Parameters

name string

The name of the attribute to insert.

value string

The value of the attribute to insert.

Returns

HtmlAttribute

The appended attribute.

AttributesWithName(string)

Returns all attributes with specified name. Handles case insentivity

public IEnumerable<HtmlAttribute> AttributesWithName(string attributeName)

Parameters

attributeName string

Name of the attribute

Returns

IEnumerable<HtmlAttribute>

Contains(HtmlAttribute)

Retreives existence of supplied item

public bool Contains(HtmlAttribute item)

Parameters

item HtmlAttribute

Returns

bool

Contains(string)

Checks for existance of attribute with given name

public bool Contains(string name)

Parameters

name string

Returns

bool

CopyTo(HtmlAttribute[], int)

Copies collection to array

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

Parameters

array HtmlAttribute[]
arrayIndex int

IndexOf(HtmlAttribute)

Retrieves the index for the supplied item, -1 if not found

public int IndexOf(HtmlAttribute item)

Parameters

item HtmlAttribute

Returns

int

Insert(int, HtmlAttribute)

Inserts given item into collection at supplied index

public void Insert(int index, HtmlAttribute item)

Parameters

index int
item HtmlAttribute

Prepend(HtmlAttribute)

Inserts the specified attribute as the first node in the collection.

public HtmlAttribute Prepend(HtmlAttribute newAttribute)

Parameters

newAttribute HtmlAttribute

The attribute to insert. May not be null.

Returns

HtmlAttribute

The prepended attribute.

Remove()

Removes all attributes from the collection

public void Remove()

Remove(HtmlAttribute)

Removes a given attribute from the list.

public void Remove(HtmlAttribute attribute)

Parameters

attribute HtmlAttribute

The attribute to remove. May not be null.

Remove(string)

Removes an attribute from the list, using its name. If there are more than one attributes with this name, they will all be removed.

public void Remove(string name)

Parameters

name string

The attribute's name. May not be null.

RemoveAll()

Remove all attributes in the list.

public void RemoveAll()

RemoveAt(int)

Removes the attribute at the specified index.

public void RemoveAt(int index)

Parameters

index int

The index of the attribute to remove.