HtmlElementCollection

Assembly: ZennoLab.CommandCenter
Full name: ZennoLab.CommandCenter.HtmlElementCollection


Represents a strongly typed list of html elements that can be accessed by index.

The HtmlElementCollection class contain the properties such as ErrorDetected and IsVoid. Their use necessary for the correct work of your code.

Properties

IsVoid

Property

Gets the specified collection is void collection or not.

Example

public static int Execute(Instance instance, IZennoPosterProjectModel project)
            {
                // clear cookie
                instance.ClearCookie();
                
                // go to lessons.zennolab.com
                Tab tab = instance.MainTab;
                if ((tab.IsVoid) || (tab.IsNull)) return -1;
                if (tab.IsBusy) tab.WaitDownloading();
                tab.Navigate("lessons.zennolab.com");
                if (tab.IsBusy) tab.WaitDownloading();
                
                // find elements by tag
                HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
                
                // if collection is void then return -1
                if (heCol.IsVoid) return -1;
                
                return 0;
            }

Example2

public static function Execute($instance, $project)
            {
                // clear cookie
                $instance->ClearCookie();
                
                // go to lessons.zennolab.com
                $tab = $instance->MainTab;
                if (($tab->IsVoid) || ($tab->IsNull)) return -1;
                if ($tab->IsBusy) $tab->WaitDownloading();
                $tab->Navigate("lessons.zennolab.com");
                if ($tab->IsBusy) $tab->WaitDownloading();
                
                // find elements by tag
                $heCol = $tab->FindElementsByTags("input:checkbox");
                
                // if collection is void then return -1
                if ($heCol->IsVoid) return -1;
                
                return 0;
            }

ErrorDetected

Property

Gets information about the error detected in the performance last command

If the HtmlElementCollection object does not indicate to the real html element collection then this property is true. Also objects of this class contains IsVoid property for identification of html element collection’s existence. Almost all classes of ZennoLab.CommandCenter contains such properties. Use it for the correct execution of the code.

Example

public static int Execute(Instance instance, IZennoPosterProjectModel project)
            {
                // clear cookie
                instance.ClearCookie();
                
                // go to lessons.zennolab.com
                Tab tab = instance.MainTab;
                if ((tab.IsVoid) || (tab.IsNull)) return -1;
                if (tab.IsBusy) tab.WaitDownloading();
                tab.Navigate("lessons.zennolab.com");
                if (tab.IsBusy) tab.WaitDownloading();
                
                // find elements by tag
                HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
                
                // if error detected then return -1
                if (heCol.ErrorDetected) return -1;
                
                return 0;
            }

Example2

public static function Execute($instance, $project)
            {
                // clear cookie
                $instance->ClearCookie();
                
                // go to lessons.zennolab.com
                $tab = $instance->MainTab;
                if (($tab->IsVoid) || ($tab->IsNull)) return -1;
                if ($tab->IsBusy) $tab->WaitDownloading();
                $tab->Navigate("lessons.zennolab.com");
                if ($tab->IsBusy) $tab->WaitDownloading();
                
                // find elements by tag
                $heCol = $tab->FindElementsByTags("input:checkbox");
                
                // if error detected then return -1
                if ($heCol->ErrorDetected) return -1;
                
                return 0;
            }

Count

Property

Gets the number of elements actually contained in the HtmlElementCollection.

The Count property it is the number of elements that are actually in the HtmlElementCollection.

Example

// find elements by tag
            HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
             
            // get count of collection
            int count = heCol.Count;

Example2

// find elements by tag
            $heCol = $tab->FindElementsByTags("input:checkbox");
             
            // get count of collection
            $count = $heCol->Count;

Elements

Property

Get copies the html elements of the HtmlElementCollection to a new array.

Example

// clear cookie
            instance.ClearCookie();
             
            // go to lessons.zennolab.com
            Tab tab = instance.MainTab;
            if ((tab.IsVoid) || (tab.IsNull)) return -1;
            if (tab.IsBusy) tab.WaitDownloading();
            tab.Navigate("lessons.zennolab.com");
            if (tab.IsBusy) tab.WaitDownloading();
             
            // find elements by tag
            HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
             
            // get an array of elements
            HtmlElement[] he = heCol.Elements;

Example2

// clear cookie
            $instance->ClearCookie();
             
            // go to lessons.zennolab.com
            $tab = $instance->MainTab;
            if (($tab->IsVoid) || ($tab->IsNull)) return -1;
            if ($tab->IsBusy) $tab->WaitDownloading();
            $tab->Navigate("lessons.zennolab.com");
            if ($tab->IsBusy) $tab->WaitDownloading();
             
            // find elements by tag
            $heCol = $tab->FindElementsByTags("input:checkbox");
             
            // get an array of elements
            $he = $heCol->Elements;

Current

Property

Gets the element in the collection at the current position of the enumerator.

Methods

GetByNumber

Method

Gets the html element by specified number.

Parameters

ПараметрОписание
numberThe zero-based number of the html element to get.

Returns: The html element at the specified number.

Example

public static int Execute(Instance instance, IZennoPosterProjectModel project)
            {
                // clear cookie
                instance.ClearCookie();
                
                // go to lessons.zennolab.com
                Tab tab = instance.MainTab;
                if ((tab.IsVoid) || (tab.IsNull)) return -1;
                if (tab.IsBusy) tab.WaitDownloading();
                tab.Navigate("lessons.zennolab.com");
                if (tab.IsBusy) tab.WaitDownloading();
                
                // find elements by tag
                HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
                
                // if any element was not found
                if (heCol.Count == 0) return -1;
                
                // get last element by index (number)
                HtmlElement he = heCol.GetByNumber(heCol.Count-1);
                
                return 0;
            }

Example2

public static function Execute($instance, $project)
            {
                // clear cookie
                $instance->ClearCookie();
                
                // go to lessons.zennolab.com
                $tab = $instance->MainTab;
                if (($tab->IsVoid) || ($tab->IsNull)) return -1;
                if ($tab->IsBusy) $tab->WaitDownloading();
                $tab->Navigate("lessons.zennolab.com");
                if ($tab->IsBusy) $tab->WaitDownloading();
                
                // find elements by tag
                $heCol = $tab->FindElementsByTags("input:checkbox");
                
                // if any element was not found
                if ($heCol->Count == 0) return -1;
                
                // get last element by index (number)
                $he = $heCol->GetByNumber($heCol->Count-1);
                
                return 0;
            }

Add

Method

Adds a html element to the end of the HtmlElementCollection.

Parameters

ПараметрОписание
elementThe html element to be added to the end of the HtmlElementCollection.

Example

public static int Execute(Instance instance, IZennoPosterProjectModel project)
            {
                // clear cookie
                instance.ClearCookie();
                
                // go to lessons.zennolab.com
                Tab tab = instance.MainTab;
                if ((tab.IsVoid) || (tab.IsNull)) return -1;
                if (tab.IsBusy) tab.WaitDownloading();
                tab.Navigate("lessons.zennolab.com");
                if (tab.IsBusy) tab.WaitDownloading();
                
                // find elments by tag
                HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
                
                // find elements by tag
                HtmlElementCollection newHeCol = tab.FindElementsByTags("input:radio");
                
                // add all elements from second to first collection
                for (int i = 0; i < newHeCol.Count; i++) heCol.Add(newHeCol.Elements[i]);
                
                return 0;
            }

Example2

public static function Execute($instance, $project)
            {
                // clear cookie
                $instance->ClearCookie();
                
                // go to lessons.zennolab.com
                $tab = $instance->MainTab;
                if (($tab->IsVoid) || ($tab->IsNull)) return -1;
                if ($tab->IsBusy) $tab->WaitDownloading();
                $tab->Navigate("lessons.zennolab.com");
                if ($tab->IsBusy) $tab->WaitDownloading();
                
                // find elments by tag
                $heCol = $tab->FindElementsByTags("input:checkbox");
                
                // find elements by tag
                $newHeCol = $tab->FindElementsByTags("input:radio");
                
                // add all elements from second to first collection
                for ($i = 0; $i < $newHeCol->Count; $i++) $heCol->Add($newHeCol->Elements[$i]);
                
                return 0;
            }

AddRange

Method

Adds the html elements of the specified collection to the end of the HtmlElementCollection.

The order of the elements in the collection is preserved in the HtmlElementCollection.

Parameters

ПараметрОписание
elementsThe collection whose html elements should be added to the end of the HtmlElementCollection. The collection itself cannot be null.

Example

public static int Execute(Instance instance, IZennoPosterProjectModel project)
            {
                // clear cookie
                instance.ClearCookie();
                
                // go to lessons.zennolab.com
                Tab tab = instance.MainTab;
                if ((tab.IsVoid) || (tab.IsNull)) return -1;
                if (tab.IsBusy) tab.WaitDownloading();
                tab.Navigate("lessons.zennolab.com");
                if (tab.IsBusy) tab.WaitDownloading();
                
                // find elements by tag
                HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
                
                // find elements by tag
                HtmlElementCollection newHeCol = tab.FindElementsByTags("input:radio");
                
                // add second collection to first
                heCol.AddRange(newHeCol);
                
                return 0;
            }

Example2

public static function Execute($instance, $project)
            {
                // clear cookie
                $instance->ClearCookie();
                
                // go to lessons.zennolab.com
                $tab = $instance->MainTab;
                if (($tab->IsVoid) || ($tab->IsNull)) return -1;
                if ($tab->IsBusy) $tab->WaitDownloading();
                $tab->Navigate("lessons.zennolab.com");
                if ($tab->IsBusy) $tab->WaitDownloading();
                
                // find elements by tag
                $heCol = $tab->FindElementsByTags("input:checkbox");
                
                // find elements by tag
                $newHeCol = $tab->FindElementsByTags("input:radio");
                
                // add second collection to first
                $heCol->AddRange($newHeCol);
                
                return 0;
            }

AddRange

Method

Adds the htm elements of the specified array to the end of the HtmlElementCollection.

The order of the elements in the collection is preserved in the HtmlElementCollection.

Parameters

ПараметрОписание
elementsThe array whose html elements should be added to the end of the HtmlElementCollection. The collection itself cannot be null.

Example

public static int Execute(Instance instance, IZennoPosterProjectModel project)
            {
                // clear cookie
                instance.ClearCookie();
                
                // go to lessons.zennolab.com
                Tab tab = instance.MainTab;
                if ((tab.IsVoid) || (tab.IsNull)) return -1;
                if (tab.IsBusy) tab.WaitDownloading();
                tab.Navigate("lessons.zennolab.com");
                if (tab.IsBusy) tab.WaitDownloading();
                
                // find elements by tag
                HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
                
                // find elements by tag
                HtmlElementCollection newHeCol = tab.FindElementsByTags("input:radio");
                
                // add second collection to first
                heCol.AddRange(newHeCol.Elements);
                
                return 0;
            }

Example2

public static function Execute($instance, $project)
            {
                // clear cookie
                $instance->ClearCookie();
                
                // go to lessons.zennolab.com
                $tab = $instance->MainTab;
                if (($tab->IsVoid) || ($tab->IsNull)) return -1;
                if ($tab->IsBusy) $tab->WaitDownloading();
                $tab->Navigate("lessons.zennolab.com");
                if ($tab->IsBusy) $tab->WaitDownloading();
                
                // find elements by tag
                $heCol = $tab->FindElementsByTags("input:checkbox");
                
                // find elements by tag
                $newHeCol = $tab->FindElementsByTags("input:radio");
                
                // add second collection to first
                $heCol->AddRange($newHeCol);
                
                return 0;
            }

Insert

Method

Inserts a html element into the HtmlElementCollection at the specified index.

If index is equal to Count, item is added to the end of HtmlElementCollection.

Parameters

ПараметрОписание
elementThe document to insert.
indexThe zero-based index at which html element should be inserted.

Example

// find elements by tag
            HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
             
            // find element by name
            HtmlElement he = instance.GetTabByAddress("page").GetDocumentByAddress("0").FindElementByName("rad");
             
            // if collection is invalid then return -1
            if ((heCol.IsVoid) || (heCol.ErrorDetected)) return -1;
             
            // insert element to collection
            heCol.Insert(he, 0);

Example2

// find elements by tag
            $heCol = $tab->FindElementsByTags("input:checkbox");
             
            // find element by name
            $he = $instance->GetTabByAddress("page")->GetDocumentByAddress("0")->FindElementByName("rad");
             
            // if collection is invalid then return -1
            if (($heCol->IsVoid) || ($heCol->ErrorDetected)) return -1;
             
            // insert element to collection
            $heCol->Insert($he, 0);

InsertRange

Method

Inserts the html element of a collection into the HtmlElementCollection at the specified index.

If index is equal to Count, the elements are added to the end of HtmlElementCollection. The order of the elements in the collection is preserved in the HtmlElementCollection.

Parameters

ПараметрОписание
elementsThe collection whose elements should be inserted into the HtmlElementCollection. The collection itself cannot be null.
indexThe zero-based index at which the new html elements should be inserted.

Example

public static int Execute(Instance instance, IZennoPosterProjectModel project)
            {
                // clear cookie
                instance.ClearCookie();
                
                // go to lessons.zennolab.com
                Tab tab = instance.MainTab;
                if ((tab.IsVoid) || (tab.IsNull)) return -1;
                if (tab.IsBusy) tab.WaitDownloading();
                tab.Navigate("lessons.zennolab.com");
                if (tab.IsBusy) tab.WaitDownloading();
                
                // find elements by tag
                HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
                if ((heCol.IsVoid) || (heCol.ErrorDetected)) return -1;
                
                // find elements by tag
                HtmlElementCollection newHeCol = tab.FindElementsByTags("input:radio");
                if ((newHeCol.IsVoid) || (newHeCol.ErrorDetected)) return -1;
                
                // insert second collection to first
                heCol.InsertRange(newHeCol, 0);
                
                return 0;
            }

Example2

public static function Execute($instance, $project)
            {
                // clear cookie
                $instance->ClearCookie();
                
                // go to lessons.zennolab.com
                $tab = $instance->MainTab;
                if (($tab->IsVoid) || ($tab->IsNull)) return -1;
                if ($tab->IsBusy) $tab->WaitDownloading();
                $tab->Navigate("lessons.zennolab.com");
                if ($tab->IsBusy) $tab->WaitDownloading();
                
                // find elements by tag
                $heCol = $tab->FindElementsByTags("input:checkbox");
                if (($heCol->IsVoid) || ($heCol->ErrorDetected)) return -1;
                
                // find elements by tag
                $newHeCol = $tab->FindElementsByTags("input:radio");
                if (($newHeCol->IsVoid) || ($newHeCol->ErrorDetected)) return -1;
                
                // insert second collection to first
                $heCol->InsertRange($newHeCol, 0);
                
                return 0;
            }

InsertRange

Method

Inserts the html element of an array into the HtmlElementCollection at the specified index.

If index is equal to Count, the elements are added to the end of HtmlElementCollection. The order of the elements in the collection is preserved in the HtmlElementCollection.

Parameters

ПараметрОписание
elementsThe array whose elements should be inserted into the HtmlElementCollection. The array itself cannot be null.
indexThe zero-based index at which the new html element should be inserted.

Example

public static int Execute(Instance instance, IZennoPosterProjectModel project)
            {
                // clear cookie
                instance.ClearCookie();
                
                // go to lessons.zennolab.com
                Tab tab = instance.MainTab;
                if ((tab.IsVoid) || (tab.IsNull)) return -1;
                if (tab.IsBusy) tab.WaitDownloading();
                tab.Navigate("lessons.zennolab.com");
                if (tab.IsBusy) tab.WaitDownloading();
                
                // find elements by tag
                HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
                if ((heCol.IsVoid) || (heCol.ErrorDetected)) return -1;
                
                // find elements by tag
                HtmlElementCollection newHeCol = tab.FindElementsByTags("input:radio");
                if ((newHeCol.IsVoid) || (newHeCol.ErrorDetected)) return -1;
                
                // insert second collection to first
                heCol.InsertRange(newHeCol.Elements, 0);
                
                return 0;
            }

Example2

public static function Execute($instance, $project)
            {
                // clear cookie
                $instance->ClearCookie();
                
                // go to lessons.zennolab.com
                $tab = $instance->MainTab;
                if (($tab->IsVoid) || ($tab->IsNull)) return -1;
                if ($tab->IsBusy) $tab->WaitDownloading();
                $tab->Navigate("lessons.zennolab.com");
                if ($tab->IsBusy) $tab->WaitDownloading();
                
                // find elements by tag
                $heCol = $tab->FindElementsByTags("input:checkbox");
                if (($heCol->IsVoid) || ($heCol->ErrorDetected)) return -1;
                
                // find elements by tag
                $newHeCol = $tab->FindElementsByTags("input:radio");
                if (($newHeCol->IsVoid) || ($newHeCol->ErrorDetected)) return -1;
                
                // insert second collection to first
                $heCol->InsertRange($newHeCol->Elements, 0);
                
                return 0;
            }

Remove

Method

Removes the element at the specified index of the HtmlElementCollection.

Parameters

ПараметрОписание
indexThe zero-based index of the html element to remove.

Example

// find elements by tag
            HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
             
            // remove last element
            heCol.Remove(heCol.Count-1);

Example2

// find elements by tag
            $heCol = $tab->FindElementsByTags("input:checkbox");
             
            // remove last element
            $heCol->Remove($heCol->Count-1);

IndexOf

Method

Searches for the specified object and returns the zero-based index of the first occurrence within the entire HtmlElementCollection.

The HtmlElementCollection is searched forward starting at index and ending at the last element.

Parameters

ПараметрОписание
elementThe document to locate in the HtmlElementCollection.

Returns: The zero-based index of the first occurrence of item within the entire HtmlElementCollection, if found; otherwise, –1.

Example

public static int Execute(Instance instance, IZennoPosterProjectModel project)
            {
                // clear cookie
                instance.ClearCookie();
                
                // go to lessons.zennolab.com
                Tab tab = instance.MainTab;
                if ((tab.IsVoid) || (tab.IsNull)) return -1;
                if (tab.IsBusy) tab.WaitDownloading();
                tab.Navigate("lessons.zennolab.com");
                if (tab.IsBusy) tab.WaitDownloading();
                
                // find elements by tag
                HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
                
                // get last element
                HtmlElement he = heCol.Elements[heCol.Count-1];
                
                // get index of 'he' in collection
                int index = heCol.IndexOf(he);
                
                return 0;
            }

Example2

public static function Execute($instance, $project)
            {
                // clear cookie
                $instance->ClearCookie();
                
                // go to lessons.zennolab.com
                $tab = $instance->MainTab;
                if (($tab->IsVoid) || ($tab->IsNull)) return -1;
                if ($tab->IsBusy) $tab->WaitDownloading();
                $tab->Navigate("lessons.zennolab.com");
                if ($tab->IsBusy) $tab->WaitDownloading();
                
                // find elements by tag
                $heCol = $tab->FindElementsByTags("input:checkbox");
                
                // get last element
                $he = $heCol->Elements[$heCol->Count-1];
                
                // get index of 'he' in collection
                $index = $heCol->IndexOf($he);
                
                return 0;
            }

AttributesToString

Method

Returns the attributes of all elements of the collection with the given name and assembles them into text. The attributes recorded through a line terminator.

Parameters

ПараметрОписание
attrNameAttribute name.

Returns: Attributes of all elements of the collection with the given name in text form.

Example

// find elements by tag
            HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
             
            // get attributes to string
            string result = heCol.AttributesToString("FullTagName");

Example2

// find elements by tag
            $heCol = $tab->FindElementsByTags("input:checkbox");
             
            // get attributes to string
            $result = $heCol->AttributesToString("FullTagName");

AttributesToString

Method

Returns the attributes of all elements of the collection with the given name and assembles them into text. The attributes recorded through the specified delimiter.

Parameters

ПараметрОписание
attrNameAttribute name.
delemiterDelimiter that separates attributes in the text.

Returns: Attributes of all elements of the collection with the given name in text form

Example

// find elements by tag
            HtmlElementCollection heCol = tab.FindElementsByTags("input:checkbox");
             
            // get attributes to string
            string result = heCol.AttributesToString("FullTagName", ":");

Example2

// find elements by tag
            $heCol = $tab->FindElementsByTags("input:checkbox");
             
            // get attributes to string
            $result = $heCol->AttributesToString("FullTagName", ":");

GetNull

Method

Возвращает пустой элемент

GetEnumerator

Method

Returns an enumerator that iterates through a collection.

Returns: An IEnumerator object that can be used to iterate through the collection.

Dispose

Method

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

MoveNext

Method

Advances the enumerator to the next element of the collection.

Reset

Method

Sets the enumerator to its initial position, which is before the first element in the collection.

Fields

ZpIds

Field

id элементов, которые находятся в этой коллекции