Re: [Htmlparser-user] How to extract the Select Tag in the Form?
Brought to you by:
derrickoswald
From: Derrick O. <Der...@Ro...> - 2006-05-07 23:59:56
|
Sue, The FormTag has a couple of methods to get INPUT and TEXTAREA tags. You should use something like those: /** * Get the list of input fields. * @return Input elements in the form. */ public NodeList getFormInputs() { return (searchFor (InputTag.class, true)); } but search for SelectTag.class and call the method getSelects(). If you want a specific named SELECT, then you should use something like the equivalent methods for INPUT and TEXTAREA: /** * Get the input tag in the form corresponding to the given name * @param name The name of the input tag to be retrieved * @return Tag The input tag corresponding to the name provided */ public InputTag getInputTag (String name) { InputTag inputTag; boolean found; String inputTagName; inputTag = null; found = false; for (SimpleNodeIterator e = getFormInputs().elements();e.hasMoreNodes() && !found;) { inputTag = (InputTag)e.nextNode(); inputTagName = inputTag.getAttribute("NAME"); if (inputTagName!=null && inputTagName.equalsIgnoreCase(name)) found=true; } if (found) return (inputTag); else return (null); } but use your new getSelects() method. Derrick sue asdic wrote: > Hi > > I want to extract the select tag from the form,how to do it? > > for example: > > the page likes this,and I want to know in the form1 there is one > select tag and in the form1 there is one select tag too! > > <html> > > <form name = form1> > <input type=text name="usrname"> > <select name="sex"> > <option value="female" selected>female</option> > <option value="male">male</option> > </select> > </form> > > <form name = form2> > <input type=text name="email"> > <select name="lang"> > <option value="english" selected>english</option> > <option value="french">french</option> > </select> > </form> > > </html> > > Regards > sue > > > ------------------------------------------------------- > Using Tomcat but need to do more? Need to support web services, security? > Get stuff done quickly with pre-integrated technology to make your job > easier > Download IBM WebSphere Application Server v.1.0.1 based on Apache > Geronimo > http://sel.as-us.falkag.net/sel?cmd=k&kid0709&bid&3057&dat1642 > _______________________________________________ > Htmlparser-user mailing list > Htm...@li... > https://lists.sourceforge.net/lists/listinfo/htmlparser-user > > |