Using AndFilter should help you to get to that value..
Here is some sample code... Sorry it is not java. But it should give you id=
ea.
static void GetValuesFromTestPage()
=09=09{
=09=09=09FileStream obFile =3D new FileStream("TestPage.htm", FileMode.Open=
);
=09=09=09Source obSource =3D new InputStreamSource(obFile);
=09=09=09Page obPage =3D new Page(obSource);
=09=09=09Lexer obLexer =3D new Lexer(obPage);
=09=09=09Parser obParser =3D new Parser(obLexer);
=09=09=09NodeFilter obTagFilter =3D new TagNameFilter("input");
=09=09=09NodeFilter obAttribFilter =3D new HasAttributeFilter("name", "disp=
layName");
=09=09=09NodeFilter andFilter =3D new AndFilter(obTagFilter, obAttribFilter=
);
=09=09=09NodeList inputs =3D obParser.ExtractAllNodesThatMatch(andFilter);
=09=09=09if (inputs !=3D null && inputs.Count =3D=3D 1)
=09=09=09{
=09=09=09=09INode obNode =3D inputs[0];
=09=09=09=09Console.WriteLine(((ITag)obNode).GetAttribute("value"));
=09=09=09}
=09=09=09obFile.Close();
HTML parser");
=09=09}
On 1/6/06, Rajat Sharma <rs...@ai...> wrote:
>
> Hi all,
>
> Looking for the best way to parse the Html Code below and extract the str=
ing
> "NELogsTransferPolicy1" which is almost at the last line of this code.
>
> Thanks,
> Raj
>
>
> <table>
> <tr>
> <td>
> <b>Select Policy To Add : </b>
> </td>
> <td>
> <select name=3D"policyToAdd" onChange=3D"setName(=
)" >
> <option
> value=3D"NELogsTransferPolicy#com.ems.policies.NELogsTransferPolicy"
> >NELogsTransferPolicy</option>
> <option
> value=3D"NEConfigFileTransferPolicy#com.ems.policies.NEConfigFileTransfer=
Policy"
> >NEConfigFileTransferPolicy</option>
> <option
> value=3D"LogLvlCfgPolicy#com.ems.policies.LogLvlCfgPolicy"
> >LogLvlCfgPolicy</option>
> <option
> value=3D"FileCleanupPolicy#com.ems.policies.FileCleanupPolicy"
> >FileCleanupPolicy</option>
> <option
> value=3D"AlarmTableCleanupPolicy#com.ems.policies.AlertTableCleanup"
> >AlarmTableCleanupPolicy</option>
> <option
> value=3D"EventTableCleanupPolicy#com.ems.policies.EventTableCleanup"
> >EventTableCleanupPolicy</option>
>
> </select>
> </td>
> </tr>
> <tr>
> <td>
> <b>Instance Name : </b>
> </td>
> <td>
> <input type=3D"text" size=3D40 maxlength=3D100
> name=3D"displayName" value=3D"NELogsTransferPolicy1">
> </td>
> </tr>
> </table>
--
Naveen K Kohli
http://www.netomatix.com
|