Saving HTML Table as xml or json

Go To StackoverFlow.com

1

I'm looking for a way to save a table from an html page as xml or json. The current method i'm using save the entire page as and xls sheet and then reads the sheet using Office.InterLop.Excel. I want to skip saving the file and just read directly from the page using HttpRequest. Any ideas?

2012-04-03 21:17
by Antarr Byrd
Are you looking to get the table in XML format, or just export the table to Excel - James Johnson 2012-04-03 21:20
@JamesJohnson I just need the XML or JSON, I would like to avoid saving it as Exce - Antarr Byrd 2012-04-03 21:21
Is it just a static table, or is the table generated from a server control, like a DataGrid or something - James Johnson 2012-04-03 21:25
@JamesJohnson its at this page http://cbtcws.cityofhouston.gov/ActiveIncidents//Combined.asp - Antarr Byrd 2012-04-03 21:26


1

I assume you mean that you'd like to scrape the contents of a web page without File-> Save As? Code project has a writeup explaining using HttpWebRequest to do just that. Or, you could use the newer HttpClient. Once you retrieve the HTML, you'll have to parse it yourself.

In the MSDN artticle, they're actually requesting JSON directly, so they don't have to deal with parsing, but you could very easily write up a RegularExpression to capture the table body.

2012-04-03 21:22
by Rob Rodi
Thanks thats what I needed - Antarr Byrd 2012-04-03 21:42