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
IsReadOnly
Gets readonly status of colelction
public bool IsReadOnly { get; }
Property Value
this[int]
Gets the attribute at the specified index.
public HtmlAttribute this[int index] { get; set; }
Parameters
index
int
Property Value
this[string]
Gets a given attribute from the list using its name.
public HtmlAttribute this[string name] { get; set; }
Parameters
name
string
Property Value
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
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
HtmlAttributeThe 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
stringThe 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
Returns
- HtmlAttribute
The appended attribute.
AttributesWithName(string)
Returns all attributes with specified name. Handles case insentivity
public IEnumerable<HtmlAttribute> AttributesWithName(string attributeName)
Parameters
attributeName
stringName of the attribute
Returns
Contains(HtmlAttribute)
Retreives existence of supplied item
public bool Contains(HtmlAttribute item)
Parameters
item
HtmlAttribute
Returns
Contains(string)
Checks for existance of attribute with given name
public bool Contains(string name)
Parameters
name
string
Returns
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
Insert(int, HtmlAttribute)
Inserts given item into collection at supplied index
public void Insert(int index, HtmlAttribute item)
Parameters
index
intitem
HtmlAttribute
Prepend(HtmlAttribute)
Inserts the specified attribute as the first node in the collection.
public HtmlAttribute Prepend(HtmlAttribute newAttribute)
Parameters
newAttribute
HtmlAttributeThe 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
HtmlAttributeThe 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
stringThe 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
intThe index of the attribute to remove.