On Sep 3, 7:05 am, yawnmoth <terra1...@yahoo.comwrote:
Quote:
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.
Indeed, if I use DOMDocument::saveHTML(), I get something more like
this:
>
<div>
<form action="">
<input type="text" name="a" />
</form>
</div>
<div>
<input type="text" name="b" />
</div>
<div>
<input type="submit" />
</div>
>
Any ideas?
I'm not sure what you're trying to achieve here I'm afraid, but I do
have one piece of advice for you. Fix your HTML. There is no reason
whatsoever for it not to be well formed, and it's only ever going to
cause you grief. If you didn't write teh HTML in question then have a
quiet polite word with whomever did.