Webbrowser GetElementsByTagName looping within that tag areaReplacing .NET WebBrowser control with a better browser, like Chrome?GetElementsByTagName not returning elements in webbrowser controlGetElementsByTagName in HtmlagilitypackHow to open text file and parse itUsing DOM (getElementsByTagName) to get “content” meta tagArray.prototype.reduce in recursive function is producing unexpected resultsgetElementsByTagName multiple tagsPhysical type Click for Webbrowser website combobox?Webbrowser Automation not loopingwebBrowser.document cannot find element

C++ lambda syntax

Can you describe someone as luxurious? As in someone who likes luxurious things?

Travelling in US for more than 90 days

What is the period/term used describe Giuseppe Arcimboldo's style of painting?

Highest stage count that are used one right after the other?

What is the tangent at a sharp point on a curve?

How would a solely written language work mechanically

Showing mass murder in a kid's book

Mortal danger in mid-grade literature

Pre-Employment Background Check With Consent For Future Checks

Is there a POSIX way to shutdown a UNIX machine?

"Marked down as someone wanting to sell shares." What does that mean?

categorizing a variable turns it from insignificant to significant

Put the phone down / Put down the phone

Trouble reading roman numeral notation with flats

How to test the sharpness of a knife?

How can a new country break out from a developed country without war?

Would this string work as string?

Did I make a mistake by ccing email to boss to others?

Writing in a Christian voice

Calculate Pi using Monte Carlo

Turning a hard to access nut?

Derivative of an interpolated function

Do I have to take mana from my deck or hand when tapping this card?



Webbrowser GetElementsByTagName looping within that tag area


Replacing .NET WebBrowser control with a better browser, like Chrome?GetElementsByTagName not returning elements in webbrowser controlGetElementsByTagName in HtmlagilitypackHow to open text file and parse itUsing DOM (getElementsByTagName) to get “content” meta tagArray.prototype.reduce in recursive function is producing unexpected resultsgetElementsByTagName multiple tagsPhysical type Click for Webbrowser website combobox?Webbrowser Automation not loopingwebBrowser.document cannot find element













0















I have a been trying to figure out how to go about doing this for some time now. I am wanting to find the form classname of "live_" which i can do just fine with the below code but i am unsure how to go about getting a text value within that form tag without looping through the whole code and getting every other form text value on the page.



I am using a webbrowser control on my winform.



The code i have to get the form tag is this:



Dim theElementCollection As HtmlElementCollection = Nothing

theElementCollection = wbNewsFeed.Document.GetElementsByTagName("form")

For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("className").ToLower.Contains("live_") Then
Dim theID As String = curElement.GetAttribute("data-live")
End If
Next


The code above currently loops until it finds no more form tags within that page. If it finds a form tag then it looks to see if that form tag contains a classname of live_ in any part of its name. This code works just fine and does find all the form tags by that class. However, some form tags still have that class but no text box that i am also wanting to search for within that form tag only.



The html looks similar to this:



<form class="live_574bf67566_58vvifkfkyu5237 commentable expand_mode" id="0_f" 
onsubmit="return window.Event &amp;&amp;" action="change.php" method="post"
data-ft='"ge":"]"' rel="async" data-live='"seq":"574bf67566_1857067654230"'>

<input name="charset_test" type="hidden" value="6,52g,6b88">
<input name="fb_dtsg" type="hidden" value="AQB4SLmU" autocomplete="off">
[LOT of code here....]
<input class="hiddenInput" type="hidden" autocomplete="off" data-id="785fgj67-774">
<div class="innerWrap" data-reactid=".1l.1:4.0.$right.0.0.0.0.1.0.1">
<textarea name="add_comment_text" title="Write a comment..." class="textInput mentions" placeholder="Write a comment..." value="Write a comment..." data-id="57-986-gn-52">Write a comment...</textarea>
</div>
[some more code here]
</form>


So my question is: How do i go about looking through only that current form tag area and finding if it has that textbox (.GetAttribute("title").ToString.ToLower = "write a comment...")?



I've tried doing the following:



Dim theElementCollection2 As HtmlElementCollection = Nothing

For Each curElement As HtmlElement In theElementCollection
If curElement.GetAttribute("className").ToLower.Contains("live_") Then
Dim theID As String = curElement.GetAttribute("data-live")

theElementCollection2 = curElement.Document.GetElementsByTagName("textarea")

For Each curElement2 As HtmlElement In theElementCollection2
Debug.Print(curElement2.GetAttribute("title").ToLower.ToString)
If curElement2.GetAttribute("title").ToLower.ToString = "write a comment..." Then
Debug.Print("Found! " & curElement2.GetAttribute("name"))
End If
Next
End If
Next


But that seems to only loop through the whole html page still...



Thanks for your time and help!










share|improve this question




























    0















    I have a been trying to figure out how to go about doing this for some time now. I am wanting to find the form classname of "live_" which i can do just fine with the below code but i am unsure how to go about getting a text value within that form tag without looping through the whole code and getting every other form text value on the page.



    I am using a webbrowser control on my winform.



    The code i have to get the form tag is this:



    Dim theElementCollection As HtmlElementCollection = Nothing

    theElementCollection = wbNewsFeed.Document.GetElementsByTagName("form")

    For Each curElement As HtmlElement In theElementCollection
    If curElement.GetAttribute("className").ToLower.Contains("live_") Then
    Dim theID As String = curElement.GetAttribute("data-live")
    End If
    Next


    The code above currently loops until it finds no more form tags within that page. If it finds a form tag then it looks to see if that form tag contains a classname of live_ in any part of its name. This code works just fine and does find all the form tags by that class. However, some form tags still have that class but no text box that i am also wanting to search for within that form tag only.



    The html looks similar to this:



    <form class="live_574bf67566_58vvifkfkyu5237 commentable expand_mode" id="0_f" 
    onsubmit="return window.Event &amp;&amp;" action="change.php" method="post"
    data-ft='"ge":"]"' rel="async" data-live='"seq":"574bf67566_1857067654230"'>

    <input name="charset_test" type="hidden" value="6,52g,6b88">
    <input name="fb_dtsg" type="hidden" value="AQB4SLmU" autocomplete="off">
    [LOT of code here....]
    <input class="hiddenInput" type="hidden" autocomplete="off" data-id="785fgj67-774">
    <div class="innerWrap" data-reactid=".1l.1:4.0.$right.0.0.0.0.1.0.1">
    <textarea name="add_comment_text" title="Write a comment..." class="textInput mentions" placeholder="Write a comment..." value="Write a comment..." data-id="57-986-gn-52">Write a comment...</textarea>
    </div>
    [some more code here]
    </form>


    So my question is: How do i go about looking through only that current form tag area and finding if it has that textbox (.GetAttribute("title").ToString.ToLower = "write a comment...")?



    I've tried doing the following:



    Dim theElementCollection2 As HtmlElementCollection = Nothing

    For Each curElement As HtmlElement In theElementCollection
    If curElement.GetAttribute("className").ToLower.Contains("live_") Then
    Dim theID As String = curElement.GetAttribute("data-live")

    theElementCollection2 = curElement.Document.GetElementsByTagName("textarea")

    For Each curElement2 As HtmlElement In theElementCollection2
    Debug.Print(curElement2.GetAttribute("title").ToLower.ToString)
    If curElement2.GetAttribute("title").ToLower.ToString = "write a comment..." Then
    Debug.Print("Found! " & curElement2.GetAttribute("name"))
    End If
    Next
    End If
    Next


    But that seems to only loop through the whole html page still...



    Thanks for your time and help!










    share|improve this question


























      0












      0








      0








      I have a been trying to figure out how to go about doing this for some time now. I am wanting to find the form classname of "live_" which i can do just fine with the below code but i am unsure how to go about getting a text value within that form tag without looping through the whole code and getting every other form text value on the page.



      I am using a webbrowser control on my winform.



      The code i have to get the form tag is this:



      Dim theElementCollection As HtmlElementCollection = Nothing

      theElementCollection = wbNewsFeed.Document.GetElementsByTagName("form")

      For Each curElement As HtmlElement In theElementCollection
      If curElement.GetAttribute("className").ToLower.Contains("live_") Then
      Dim theID As String = curElement.GetAttribute("data-live")
      End If
      Next


      The code above currently loops until it finds no more form tags within that page. If it finds a form tag then it looks to see if that form tag contains a classname of live_ in any part of its name. This code works just fine and does find all the form tags by that class. However, some form tags still have that class but no text box that i am also wanting to search for within that form tag only.



      The html looks similar to this:



      <form class="live_574bf67566_58vvifkfkyu5237 commentable expand_mode" id="0_f" 
      onsubmit="return window.Event &amp;&amp;" action="change.php" method="post"
      data-ft='"ge":"]"' rel="async" data-live='"seq":"574bf67566_1857067654230"'>

      <input name="charset_test" type="hidden" value="6,52g,6b88">
      <input name="fb_dtsg" type="hidden" value="AQB4SLmU" autocomplete="off">
      [LOT of code here....]
      <input class="hiddenInput" type="hidden" autocomplete="off" data-id="785fgj67-774">
      <div class="innerWrap" data-reactid=".1l.1:4.0.$right.0.0.0.0.1.0.1">
      <textarea name="add_comment_text" title="Write a comment..." class="textInput mentions" placeholder="Write a comment..." value="Write a comment..." data-id="57-986-gn-52">Write a comment...</textarea>
      </div>
      [some more code here]
      </form>


      So my question is: How do i go about looking through only that current form tag area and finding if it has that textbox (.GetAttribute("title").ToString.ToLower = "write a comment...")?



      I've tried doing the following:



      Dim theElementCollection2 As HtmlElementCollection = Nothing

      For Each curElement As HtmlElement In theElementCollection
      If curElement.GetAttribute("className").ToLower.Contains("live_") Then
      Dim theID As String = curElement.GetAttribute("data-live")

      theElementCollection2 = curElement.Document.GetElementsByTagName("textarea")

      For Each curElement2 As HtmlElement In theElementCollection2
      Debug.Print(curElement2.GetAttribute("title").ToLower.ToString)
      If curElement2.GetAttribute("title").ToLower.ToString = "write a comment..." Then
      Debug.Print("Found! " & curElement2.GetAttribute("name"))
      End If
      Next
      End If
      Next


      But that seems to only loop through the whole html page still...



      Thanks for your time and help!










      share|improve this question
















      I have a been trying to figure out how to go about doing this for some time now. I am wanting to find the form classname of "live_" which i can do just fine with the below code but i am unsure how to go about getting a text value within that form tag without looping through the whole code and getting every other form text value on the page.



      I am using a webbrowser control on my winform.



      The code i have to get the form tag is this:



      Dim theElementCollection As HtmlElementCollection = Nothing

      theElementCollection = wbNewsFeed.Document.GetElementsByTagName("form")

      For Each curElement As HtmlElement In theElementCollection
      If curElement.GetAttribute("className").ToLower.Contains("live_") Then
      Dim theID As String = curElement.GetAttribute("data-live")
      End If
      Next


      The code above currently loops until it finds no more form tags within that page. If it finds a form tag then it looks to see if that form tag contains a classname of live_ in any part of its name. This code works just fine and does find all the form tags by that class. However, some form tags still have that class but no text box that i am also wanting to search for within that form tag only.



      The html looks similar to this:



      <form class="live_574bf67566_58vvifkfkyu5237 commentable expand_mode" id="0_f" 
      onsubmit="return window.Event &amp;&amp;" action="change.php" method="post"
      data-ft='"ge":"]"' rel="async" data-live='"seq":"574bf67566_1857067654230"'>

      <input name="charset_test" type="hidden" value="6,52g,6b88">
      <input name="fb_dtsg" type="hidden" value="AQB4SLmU" autocomplete="off">
      [LOT of code here....]
      <input class="hiddenInput" type="hidden" autocomplete="off" data-id="785fgj67-774">
      <div class="innerWrap" data-reactid=".1l.1:4.0.$right.0.0.0.0.1.0.1">
      <textarea name="add_comment_text" title="Write a comment..." class="textInput mentions" placeholder="Write a comment..." value="Write a comment..." data-id="57-986-gn-52">Write a comment...</textarea>
      </div>
      [some more code here]
      </form>


      So my question is: How do i go about looking through only that current form tag area and finding if it has that textbox (.GetAttribute("title").ToString.ToLower = "write a comment...")?



      I've tried doing the following:



      Dim theElementCollection2 As HtmlElementCollection = Nothing

      For Each curElement As HtmlElement In theElementCollection
      If curElement.GetAttribute("className").ToLower.Contains("live_") Then
      Dim theID As String = curElement.GetAttribute("data-live")

      theElementCollection2 = curElement.Document.GetElementsByTagName("textarea")

      For Each curElement2 As HtmlElement In theElementCollection2
      Debug.Print(curElement2.GetAttribute("title").ToLower.ToString)
      If curElement2.GetAttribute("title").ToLower.ToString = "write a comment..." Then
      Debug.Print("Found! " & curElement2.GetAttribute("name"))
      End If
      Next
      End If
      Next


      But that seems to only loop through the whole html page still...



      Thanks for your time and help!







      vb.net dom webbrowser-control html-agility-pack getelementsbytagname






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Mar 27 '14 at 0:59







      StealthRT

















      asked Mar 27 '14 at 0:24









      StealthRTStealthRT

      4,67227138257




      4,67227138257






















          1 Answer
          1






          active

          oldest

          votes


















          0














          Seems like you need:



          curElement.Children.GetElementsByName("add_comment_text")(0)





          share|improve this answer






















            Your Answer






            StackExchange.ifUsing("editor", function ()
            StackExchange.using("externalEditor", function ()
            StackExchange.using("snippets", function ()
            StackExchange.snippets.init();
            );
            );
            , "code-snippets");

            StackExchange.ready(function()
            var channelOptions =
            tags: "".split(" "),
            id: "1"
            ;
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function()
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled)
            StackExchange.using("snippets", function()
            createEditor();
            );

            else
            createEditor();

            );

            function createEditor()
            StackExchange.prepareEditor(
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader:
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            ,
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22675868%2fwebbrowser-getelementsbytagname-looping-within-that-tag-area%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            0














            Seems like you need:



            curElement.Children.GetElementsByName("add_comment_text")(0)





            share|improve this answer



























              0














              Seems like you need:



              curElement.Children.GetElementsByName("add_comment_text")(0)





              share|improve this answer

























                0












                0








                0







                Seems like you need:



                curElement.Children.GetElementsByName("add_comment_text")(0)





                share|improve this answer













                Seems like you need:



                curElement.Children.GetElementsByName("add_comment_text")(0)






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered May 4 '14 at 7:31









                shmoselshmosel

                36.8k43996




                36.8k43996





























                    draft saved

                    draft discarded
















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid


                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.

                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function ()
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f22675868%2fwebbrowser-getelementsbytagname-looping-within-that-tag-area%23new-answer', 'question_page');

                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    Popular posts from this blog

                    Save data to MySQL database using ExtJS and PHP [closed]2019 Community Moderator ElectionHow can I prevent SQL injection in PHP?Which MySQL data type to use for storing boolean valuesPHP: Delete an element from an arrayHow do I connect to a MySQL Database in Python?Should I use the datetime or timestamp data type in MySQL?How to get a list of MySQL user accountsHow Do You Parse and Process HTML/XML in PHP?Reference — What does this symbol mean in PHP?How does PHP 'foreach' actually work?Why shouldn't I use mysql_* functions in PHP?

                    Compiling GNU Global with universal-ctags support Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Data science time! April 2019 and salary with experience The Ask Question Wizard is Live!Tags for Emacs: Relationship between etags, ebrowse, cscope, GNU Global and exuberant ctagsVim and Ctags tips and trickscscope or ctags why choose one over the other?scons and ctagsctags cannot open option file “.ctags”Adding tag scopes in universal-ctagsShould I use Universal-ctags?Universal ctags on WindowsHow do I install GNU Global with universal ctags support using Homebrew?Universal ctags with emacsHow to highlight ctags generated by Universal Ctags in Vim?

                    Add ONERROR event to image from jsp tldHow to add an image to a JPanel?Saving image from PHP URLHTML img scalingCheck if an image is loaded (no errors) with jQueryHow to force an <img> to take up width, even if the image is not loadedHow do I populate hidden form field with a value set in Spring ControllerStyling Raw elements Generated from JSP tagds with Jquery MobileLimit resizing of images with explicitly set width and height attributeserror TLD use in a jsp fileJsp tld files cannot be resolved