0

I have the below Html code

<div class='blah'>...<div>
<div class='ct-bottom'>
  <button A>A</Button>
  <button B>B</Button>
</div>

I am trying to use C# SHDocVw to find the div element and get the children out of it. Here is the C# code

SHDocVw.InternetExplorer IE = new SHDocVw.InternetExplorer();
IE.Navigate(Url_Home);

foreach (HTMLDivElementClass div in IE.Document.GetElementsByClassName("ct-bottom"))
{
    if (div.innerHTML !=null )
    {
        Console.WriteLine(div.children.length); // This does not work !
        break;
    }
}

Error Message:

'object' does not contain a definition for 'length' and no extension method 'length' accepting a first argument of type 'object' could be found

ppau2004
  • 193
  • 2
  • 3
  • 16

1 Answers1

0

Worked out a way, but appreciate if there is any other ways you can share.

foreach (HTMLDivElementClass div in IE.Document.GetElementsByClassName("ct-bottom"))
{
  if (div.innerHTML != null)
  {
     Console.WriteLine((IHTMLElement)((IHTMLElementCollection)((IHTMLElement)div).children).length);
     break;
  }
}
ppau2004
  • 193
  • 2
  • 3
  • 16