getting all the input elements of a form tag

Discussion in 'XML' started by yawnmoth, Jul 16, 2008.

  1. yawnmoth

    yawnmoth Guest

    I'm trying to get a list of all the input elements of a form tag and
    am having some difficulty doing so. First, here's my XHTML:

    <div>
    <form action="">
    <input type="text" name="a" />
    </div>
    <div>
    <input type="text" name="b" />
    </div>
    <div>
    <input type="submit" />
    </form>
    </div>

    It isn't semantically correct XHTML but that doesn't stop web
    developers from coding like that.

    Anyway, in both Firefox and IE, if you visit a webpage containing the
    above, and hit the Submit button, the resultant URL will have both a
    and b defined via GET.

    I'd like to be able to get a list of the same input parameters that
    the browser does for a given form element. I had been using "//
    form[1]//input" as an XPath query, but that doesn't work, here,
    because not all of the inputs are children of the form element.

    Any ideas?
     
    yawnmoth, Jul 16, 2008
    #1
    1. Advertising

  2. yawnmoth schrieb:
    > I'm trying to get a list of all the input elements of a form tag and
    > am having some difficulty doing so. First, here's my XHTML:
    >
    > <div>
    > <form action="">
    > <input type="text" name="a" />
    > </div>
    > <div>
    > <input type="text" name="b" />
    > </div>
    > <div>
    > <input type="submit" />
    > </form>
    > </div>
    >
    > It isn't semantically correct XHTML


    It's not well-formed, so it's not XML, so it's not XHTML.

    > but that doesn't stop web
    > developers from coding like that.


    It's tag soup, but why do they call it XHTML?

    > Anyway, in both Firefox and IE, if you visit a webpage containing the
    > above, and hit the Submit button, the resultant URL will have both a
    > and b defined via GET.
    >
    > I'd like to be able to get a list of the same input parameters that
    > the browser does for a given form element. I had been using "//
    > form[1]//input" as an XPath query, but that doesn't work, here,
    > because not all of the inputs are children of the form element.


    Your parser has to reorganize the crap markup in order to create the
    DOM, which, I assume, you execute the XPath query on. So check the DOM
    that your parser creates.

    --
    Johannes Koch
    In te domine speravi; non confundar in aeternum.
    (Te Deum, 4th cent.)
     
    Johannes Koch, Jul 17, 2008
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. shruds
    Replies:
    1
    Views:
    836
    John C. Bollinger
    Jan 27, 2006
  2. Replies:
    3
    Views:
    395
  3. André
    Replies:
    2
    Views:
    736
    André
    Jun 23, 2008
  4. john woo
    Replies:
    1
    Views:
    152
    David Dorward
    Jun 29, 2005
  5. Replies:
    4
    Views:
    190
Loading...

Share This Page