I’m reading in a huge HTML string that has some info I need to extract from it. I can set up the search parameters (where to parse), but how can I achieve this without saving to a temp file then using StreamReader?
Example:
//Pertinent data starts here:
<!--
body for the page starts here
-->
<table border="0" >
<tr>
<td class='HeaderTD'><b>User Name</b></td>
<td class='HeaderTD'><b>Mark TheMan</b></td>
</tr>
<tr>
<td class='DataTD_Black_Bold '>Department</td>
<td class='DataTD'>Programming</td>
</tr>
<tr>
<td class='DataTD_Black_Bold '>Office Phone</td>
<td class='DataTD'>555-555-5555</td>
</tr>
<tr>
<td class='DataTD_Black_Bold '>Office Ext</td>
<td class='DataTD'>x5555</td>
I need to just set some attributes in a class to the various fields (which are strings):
User.UserName = "Mark TheMan";
User.Department = "Programming";
User.OfficePhone = "555-555-5555";
etc.
You see I need to search for a line that contains something like "<b>User Name</b>" then return the next line so I can parse out the desired data. Let me know if you need more info, thanks!
You should use Html parser, HtmlAgilityPack is very good.
Here is a little console application to show you how easy is to rip the data from tables :
And for your example output will be :