Results 1 to 7 of 7

Thread: Get Array From Web Page

  1. #1

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    14

    Get Array From Web Page

    I have a VB application with a webbrowser. I would like to populate a combobox on my app with the values from a specific combobox on a webpage in the browser.

    The first step seems to be getting the values from the array in the web page. Here is some code from the webpage source:

    Code:
    <script type="text/javascript">
    <!--
      var opts = new Array(5);
      var values = new Array(5);
      var clients = new Array()
      clients.name = 'clients'
      var clientsPro = new Array()
      clientsPro.name = 'clientsPro'
    The 'clients' array has the values that i want to use in my application. How do get them?

  2. #2
    Frenzied Member stateofidleness's Avatar
    Join Date
    Jan 2009
    Posts
    1,780

    Re: Get Array From Web Page

    Parse the HTML source of the page for the "<option>" tags. The .InnerText (I believe) property will hold the values you need.

    You can add them to an array or a List as you parse.

    Here's a quick reference for parsing the HTML: http://stateofidleness.com/2011/01/l...trieve-values/

  3. #3

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    14

    Re: Get Array From Web Page

    That works, except that there are 6 select boxes on the page, and I only want the values from one of them. Is there a good way to narrow down which <option> tags i want to select?

  4. #4
    Addicted Member
    Join Date
    Aug 2009
    Posts
    227

    Re: Get Array From Web Page

    Of course there is. Could you give a link to the page you're wanting to do this on?
    If I helped you with a problem, please rate me and mark your thread as resolved!

  5. #5

    Thread Starter
    New Member
    Join Date
    Feb 2011
    Posts
    14

    Re: Get Array From Web Page

    Actually, i just figured it out!

    Code:
    WebBrowser1.Document.GetElementById("copyClient").GetElementsByTagName("option")

    It grabs all the option elements in the copyClient dropdown box. Thanks!

  6. #6

  7. #7
    Addicted Member
    Join Date
    Aug 2009
    Posts
    227

    Re: Get Array From Web Page

    Glad you figured it out.
    If I helped you with a problem, please rate me and mark your thread as resolved!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width