RE: [Htmlparser-user] Best way to parse this html code
Brought to you by:
derrickoswald
From: Rajat S. <rs...@ai...> - 2006-01-06 22:24:28
|
Thanks=20 This works just fine !=20 -----Original Message----- From: htm...@li... [mailto:htm...@li...]On Behalf Of Third Eye Sent: Friday, January 06, 2006 11:42 AM To: htm...@li... Subject: Re: [Htmlparser-user] Best way to parse this html code 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 = idea. static void GetValuesFromTestPage() { FileStream obFile =3D new FileStream("TestPage.htm", FileMode.Open); Source obSource =3D new InputStreamSource(obFile); Page obPage =3D new Page(obSource); Lexer obLexer =3D new Lexer(obPage); Parser obParser =3D new Parser(obLexer); NodeFilter obTagFilter =3D new TagNameFilter("input"); NodeFilter obAttribFilter =3D new HasAttributeFilter("name", = "displayName"); NodeFilter andFilter =3D new AndFilter(obTagFilter, obAttribFilter); NodeList inputs =3D obParser.ExtractAllNodesThatMatch(andFilter); if (inputs !=3D null && inputs.Count =3D=3D 1) { INode obNode =3D inputs[0]; Console.WriteLine(((ITag)obNode).GetAttribute("value")); } obFile.Close(); HTML parser"); } 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 = string > "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 ------------------------------------------------------- This SF.net email is sponsored by: Splunk Inc. Do you grep through log = files for problems? Stop! Download the new AJAX search engine that makes searching your log files as easy as surfing the web. DOWNLOAD SPLUNK! http://ads.osdn.com/?ad_idv37&alloc_id=16865&op=3Dick _______________________________________________ Htmlparser-user mailing list Htm...@li... https://lists.sourceforge.net/lists/listinfo/htmlparser-user |