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

                    1928 у кіно

                    Захаров Федір Захарович

                    Ель Греко