Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. html control parsing

html control parsing

Scheduled Pinned Locked Moved C#
regexhtmljsonquestion
7 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • E Offline
    E Offline
    Eli Nurman
    wrote on last edited by
    #1

    hi to all. i have a html file that contains a "select" control (dropdown) with a few "option"s i need to read the option and the value of each of them, is it possible to load a html code into a HtmlDocument and then read the control by getElemementByName? Or does any one have the regex pattern to read the options and values of a dropdown control? Thanks

    L P 2 Replies Last reply
    0
    • E Eli Nurman

      hi to all. i have a html file that contains a "select" control (dropdown) with a few "option"s i need to read the option and the value of each of them, is it possible to load a html code into a HtmlDocument and then read the control by getElemementByName? Or does any one have the regex pattern to read the options and values of a dropdown control? Thanks

      L Offline
      L Offline
      led mike
      wrote on last edited by
      #2

      Eli Nurman wrote:

      is it possible to load a html code into a HtmlDocument and then read the control by getElemementByName?

      Yes. However if it is XHTML it would be simpler to use an XML Parser

      led mike

      E 1 Reply Last reply
      0
      • L led mike

        Eli Nurman wrote:

        is it possible to load a html code into a HtmlDocument and then read the control by getElemementByName?

        Yes. However if it is XHTML it would be simpler to use an XML Parser

        led mike

        E Offline
        E Offline
        Eli Nurman
        wrote on last edited by
        #3

        how is that possible to to?

        L 1 Reply Last reply
        0
        • E Eli Nurman

          hi to all. i have a html file that contains a "select" control (dropdown) with a few "option"s i need to read the option and the value of each of them, is it possible to load a html code into a HtmlDocument and then read the control by getElemementByName? Or does any one have the regex pattern to read the options and values of a dropdown control? Thanks

          P Offline
          P Offline
          Patrick Etc
          wrote on last edited by
          #4

          Try Html Agility Pack: http://www.codeplex.com/htmlagilitypack[^] For a one-off it may be overkill, but if you're going to be doing alot of html parsing it can be incredibly useful to use xpath on html.

          E 1 Reply Last reply
          0
          • P Patrick Etc

            Try Html Agility Pack: http://www.codeplex.com/htmlagilitypack[^] For a one-off it may be overkill, but if you're going to be doing alot of html parsing it can be incredibly useful to use xpath on html.

            E Offline
            E Offline
            Eli Nurman
            wrote on last edited by
            #5

            after getting the inner html of the control how do i process it? i need a regex pattern

            P 1 Reply Last reply
            0
            • E Eli Nurman

              after getting the inner html of the control how do i process it? i need a regex pattern

              P Offline
              P Offline
              Patrick Etc
              wrote on last edited by
              #6

              Eli Nurman wrote:

              after getting the inner html of the control how do i process it? i need a regex pattern

              Have you ever used xpath before? With xpath, you can do something like htmlDoc.SelectNodes("//yoursubdiv/your_option_box/select"); And you will get a collection of nodes back whose values are the text of the selections. No need for regex, no need for html parsing. This is the best suggestion I can make. Otherwise you'll need to spend some time studying regex and figuring out the exact pattern required to pick out the right dropdown, etc. It can be an irritating and mind-numbing process. If your document is guaranteed to be XHTML valid, you can even use Xml navigators straight out of the .NET framework with no need to use the Html Agility Pack (HAP is designed to provide XPATH functionality to html documents, which are not strict xml and so will not validate in the XmlDocument constructor).

              1 Reply Last reply
              0
              • E Eli Nurman

                how is that possible to to?

                L Offline
                L Offline
                led mike
                wrote on last edited by
                #7

                Eli Nurman wrote:

                how is that possible to to?

                Not sure what they call it on the planet you come from, but round here we call it programming. ;)

                led mike

                1 Reply Last reply
                0
                Reply
                • Reply as topic
                Log in to reply
                • Oldest to Newest
                • Newest to Oldest
                • Most Votes


                • Login

                • Don't have an account? Register

                • Login or register to search.
                • First post
                  Last post
                0
                • Categories
                • Recent
                • Tags
                • Popular
                • World
                • Users
                • Groups