How to get value from any tag in web browser control using wpf

前端 未结 1 1865
执笔经年
执笔经年 2020-12-22 05:18

I have a whole web page source code in a string type variable.

These code is given below:-




        
相关标签:
1条回答
  • 2020-12-22 05:37

    If you use System.Windows.Controls.WebBrowser control then this should work, however it works on assumption that you only have one CODE tag:

    var myTagValue = (wbBrowser.Document as mshtml.HTMLDocument)
                       .getElementsByTagName("CODE")
                       .OfType<mshtml.IHTMLElement>()
                       .First()
                       .innerText
    

    You'll need to reference Internet Explorer's COM library: Microsoft HTML Object Library. getElementsByTagName returns you list of all matching tags, no matter where they are in HTML

    0 讨论(0)
提交回复
热议问题