开发者

Multiple mshtml problems

开发者 https://www.devze.com 2023-03-04 03:28 出处:网络
I use an IE object in my app, so I have to use mshtml to interact with the IE\'s document. But I have several problems:

I use an IE object in my app, so I have to use mshtml to interact with the IE's document. But I have several problems:

I. Using element.innerText/innerHTML/outerText/outerHTML returns className. Here's the code example:

    public SHDocVw.InternetExplorer internetExplorer = new SHDocVw.InternetExp开发者_StackOverflow中文版lorer();

    <...>

    foreach (mshtml.HTMLSpanElement element in webBrowser.Document.GetElementsByTagName("SPAN"))
            {
                if (category.className == "classNameNeeded") //ClassName returns className
                    {
                        if (category.innerText == "InnerTextNeeded") //InnerText too 
                        {
                             webBrowser.Navigate(category.parentElement.getAttribute("HREF"));
                             return true;
                        }
                    }
            }
            return false;

So my app works incorrectly

II. Using getElementById returns DBNull instead of element on a webpage. I'm completely sure that there's such an element on a webpage. Code example:

    if(!webBrowser.Document.getElementById("IdNeeded").Equals(DBNull.value)){
    <...>
    }

I think that this problem is connected with HTML code of the page and it's parsing.

How can I solve these problems?

Thanks in advance.

0

精彩评论

暂无评论...
验证码 换一张
取 消