I have parsed my HTML/JSP into DOM at compile time using JAVA. Now I have the w3c.dom.Document object with me, let’s say for the below HTML
.....
....
<input type="text" name="EnterName"/>
<select name="SelectOptions">
<option>First</option>
<option>Second</option>
</select>
......
.......
I know the attributes values of the elements. Here “EnterName” is the “name” attributes value of the node “input”.
Suppose I have attributes values of all nodes available in DOM (like “EnterName”, “SelectOptions” of above HTML), how do I can get a node in which a particular attribute is available with the given value. Thanks
EDIT :
I will never know whats the HTML contents. My program should run on
given list of HTML/JSP files and I have with me some element names.
Here the element name refers to the label/name of the fields available
in the HTML/JSP. So I need to traverse through all the files get the
node where it has the same label/name and get the node.
Try something like this:
If you could add the “id” to your elements then its much easier: