Note that there are some explanatory texts on larger screens.

plurals
  1. POUsing MSHTML in VB.Net to parse HTML
    primarykey
    data
    text
    <p>Was wondering if someone could give me some direction on this. I've spent a decent amount of time on it and don't seem to be getting anywhere:</p> <p>I have a hidden field that I'm trying to parse out of an HTML document in VB.Net. I'm using a System.Windows.Controls.WebBrowser control in a WPF application and handling the LoadCompleted event. Inside the LoadCompleted event handler I do something like this:</p> <pre><code>Dim htmlDocument As mshtml.IHTMLDocument2 = Me.WebBrowser.Document Dim allElements As mshtml.IHTMLElementCollection = htmlDocument.body.all Dim hiddenField As mshtml.IHTMLInputElement = allElements.tags("hidField") </code></pre> <p>The hidden field that I'm trying to access is declared in my .aspx file as such:</p> <pre><code>&lt;asp:HiddenField runat="server" ID="hidField"/&gt; </code></pre> <p>The problem is that this <code>allElements.tags("hidField")</code> is returning null. Am I doing something wrong with the mshtml library? I don't have much experience with it and gathered that I needed to do something like this to find my hidden field element. Let me know if you need more info. Thanks for the help in advance.</p> <p><strong>EDIT</strong> <br>Here's is my final working solution for anyone interested:</p> <pre><code> Dim htmlDocument As mshtml.IHTMLDocument2 = Me.WebBrowser.Document Dim allElements As mshtml.IHTMLElementCollection = htmlDocument.body.all Dim allInputs As mshtml.IHTMLElementCollection = allElements.tags("input") For Each element As mshtml.IHTMLInputElement In allInputs If element.type = "hidden" And element.name.Contains("hidField") Then MessageBox.Show(element.value) End If Next </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload