**http://www.dsebd.org/latest_PE_all2_08.php**
above url contain a html table.I want to save this table value on XML and also want to save this table value on database MS2008.
How to save html table values on database
**http://www.dsebd.org/latest_PE_all2_08.php**
above url contain a html table.I want to save this table value on XML and also want to save this table value on database MS2008.
How to save html table values on database
Actually, on a typical dynamic HTML page, the table's values are loaded from the database. But, if you want, you can still parse the page's source, and save every row's values into your database. Is that what you want to do?
Hi,
You could use HTML Agility pack like so:
WebClient webClient = new WebClient();
const string strUrl = "http://www.myspace.com/centuryman";
// Setup proxy for internal stuff
//System.Net.WebProxy pry = new System.Net.WebProxy("194.80.164.8", 80);
//pry.Credentials = CredentialCache.DefaultCredentials;
//WebRequest.DefaultWebProxy = pry;
Stream s = webClient.OpenRead(strUrl);
HtmlDocument doc = new HtmlDocument();
doc.Load(s);
HtmlNode link = doc.DocumentNode.SelectNodes("//*[@id='profile_bandschedule']")[0];
This would return you a enumarable object which you could loop around and insert values of the html into the database.
See another example:
http://stackoverflow.com/questions/846994/how-to-use-html-agility-pack
You can parse the table with jQuery, create client side array or object and send it back to the server with an AJAX call or form post.
HTML:
<!DOCTYPE html>
<html>
<head>
<script class="jsbin" src="http://ajax.googleapis.com/ajax/libs/jquery/1.4.2/jquery.min.js"></script>
<meta charset=utf-8 />
<title>JS Bin</title>
<!--[if IE]>
<script src="http://html5shiv.googlecode.com/svn/trunk/html5.js"></script>
<![endif]-->
</head>
<body>
<table id="tableData">
<tr id="tableHeader">
<td>col1</td>
<td>col2</td>
</tr>
<tr id="tableRow">
<td>data1row1</td>
<td>data2row2</td>
</tr>
<tr id="tableRow">
<td>data1row2</td>
<td>data2row3</td>
</tr>
</table>
</body>
</html>
SCRIPT:
$(document).ready(function() {
//parse all the data
$('#tableData tr').each(function() {
if($(this).attr('id')=='tableHeader')
{
alert('this is the header row');
}
$('td', this).each(function() {
alert($(this).html());
});
});
//post the form or send data via AJAX
});