Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C# HTML Parsing
I am working on a project wherein I have to extract data from a website & store in acess. I am able to read data from a website & store it in html doc but now I want to parse the html doc & store in access. The following are the contents of the html file,
<HTML><HEAD><TITLE>NCEDC_Search_Results</TITLE></HEAD><BODY>Your search parameters are:
 
<ul>
<li>start_time=2002/01/01,00:00:00
<li>end_time=2037/01/01,00:00:00
<li>minimum_magnitude=3.0
<li>maximum_magnitude=10
<li>etype=E
<li>rflag=A,F,H,I
<li>system=selected
<li>format=ncread
</ul>
<PRE>
Date       Time             Lat       Lon  Depth   Mag Magt  Nst Gap  Clo  RMS  SRC   Event ID
----------------------------------------------------------------------------------------------
2002/01/10 00:44:51.53  40.4415 -126.0167  25.37  3.92   Md   56 269  147 0.29 NCSN   21208454
2002/01/12 04:41:46.93  36.7690 -121.4812   7.74  3.06   Md   54  35    5 0.09 NCSN   21208721
2002/01/12 21:52:50.82  41.1998 -124.2370  18.97  3.32   ML   11 226   19 0.03 NCSN   21208790
2002/01/16 15:29:20.88  35.7650 -121.2815   5.72  3.24   ML   47 149    6 0.09 NCSN   21209284
 

</PRE>
</BODY></HTML>
 
I want the contents between <pre></pre> tag. The column names are as given in the above html docs.
 
How can I achieve this using Html Agility Pack in C#?
i tried this code
string txt=null;
HtmlDocument doc = new HtmlDocument();
doc.LoadHtml("E://text.html");
HtmlNode node = doc.DocumentNode;
HtmlNodeCollection pre = node.SelectNodes("//pre");
//var prenodes = doc.DocumentNode.SelectNodes("//pre");
if (pre != null)
{

 

 
}

Console.ReadKey();
 

}
hw to proceed further?
Posted 10-Jul-13 8:39am
Edited 11-Jul-13 9:01am
v2
Comments
Sergey Alexandrovich Kryukov at 10-Jul-13 14:42pm
   
Not a question, just a work to be done. What help do you expect? Please start here: http://www.whathaveyoutried.com.
 
By the way, this "pre" form of XML majorly defeats the purpose of XML. This is pretty much the same as using text files.
—SA
Member 8657306 at 11-Jul-13 13:51pm
   
i want the method/technique to approach this prob..

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 BillWoodruff 260
1 Afzaal Ahmad Zeeshan 252
2 OriginalGriff 251
3 Mathew Soji 234
4 Maciej Los 230
0 OriginalGriff 6,419
1 Sergey Alexandrovich Kryukov 6,008
2 DamithSL 5,183
3 Manas Bhardwaj 4,673
4 Maciej Los 4,070


Advertise | Privacy | Mobile
Web03 | 2.8.1411019.1 | Last Updated 11 Jul 2013
Copyright © CodeProject, 1999-2014
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100