Hi there,
I have an email which has the body as an HTML table and I need to read every row and output the values as an XML.
Any suggestions on how to achieve this ?
Regards,
Loading
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend4days leftRegister
Sam HobbsRank #108 · 20.5K reputationPosted Oct 23, 2010, 10:53 AM EDT
I am assuming that you have read my article, especially the part about HtmlDocument and HTMLDocument.
First add a reference to "Microsoft HTML Object Library"; it is a COM Object, not in the .Net library. Then the following console program shows how to get HTML into an HTML document.
Suthish NairRank #92 · 22.8K reputationPosted Oct 24, 2010, 9:27 AM EDT
using (StreamReader reader = new StreamReader(Server.MapPath("email.html"))) { String line = String.Empty; while ((line=reader.ReadLine()) != null) {refer for xml conversion...
http://www.ibm.com/developerworks/library/x-tiptidy.html
http://www.example-code.com/csharp/html2xml.asp
Sam HobbsRank #108 · 20.5K reputationPosted Oct 23, 2010, 2:00 AM EDT
Another possibility would be to copy the table to the clipboard and then paste the table into Excel or Access or a similar application. That might not work but it will be relatively easy to try.
Schuster Efigenio20 reputationPosted Oct 23, 2010, 2:11 AM EDT
Sam HobbsRank #108 · 20.5K reputationPosted Oct 23, 2010, 2:25 AM EDT
If I misunderstand what you mean by "reading the body of the email in its HTML form" then you need to be more clear; there are multiple possible interpretations.
Schuster Efigenio20 reputationPosted Oct 23, 2010, 9:02 AM EDT
Let me explain further, when I read email body I need to cast it in HTML or a way of obtaining the HTML that I see when viewing the source in outlook. At present I am only able to store that contents in a string variable but I require the contents in its HTML form.
Hope that helps.
Schuster Efigenio20 reputationPosted Oct 24, 2010, 1:45 AM EDT
Got a bit further. I have now got the email in HTML but having troubles reading all the data.
I have attached the HTML page.
Sam HobbsRank #108 · 20.5K reputationPosted Oct 24, 2010, 6:50 PM EDT
Suthish NairRank #92 · 22.8K reputationPosted Oct 25, 2010, 12:08 AM EDT
Schuster Efigenio20 reputationPosted Oct 25, 2010, 3:26 AM EDT
Yes, it is frustrating I want to basically get all the table row values in Document.body.innerHTML and store them in a string array.
I have spend some time trying several ways but to no end.
thanks for your help.
I will try suthish's suggestion and links and see if i can solve my issue.
Schuster Efigenio20 reputationPosted Oct 25, 2010, 6:14 AM EDT
I have found an HTML agility pack and the does pretty much everything you would want to with HTML.
just if you need this for future reference.
regards,