Read data from html file
-
Hi, i want to read data from the source file of 3rd party website. The page is not in my control. Here i need to do two things. a. I just read the html content of that page in to string first b. and later i want to retrive some specific data from that string. the first option is ok. The second option i am not getting how to retive the data.
<tr>
<th>First Name</th>
<td width="100%"><input name="p_first_name" type="text" id="f-first-name" value="JEAN" /></td>
</tr>
<tr class="tr-back">
<th class="tr-back">Last Name</th>
<td><input name="p_last_name" type="text" id="f-last-name" value="AAREN" /></td>
</tr>
<tr>
<th>Occupation</th>
<td width="100%"><input name="o_occ" type="text" id="f-occ" value="UNKNOWN" /></td>
</tr>In the above code i want to retrive the values first name, middle name and lastname. i.e JEAN, AAREN, UNKNOWN Can any one help me how to retrive this code once reading all this html in to string..? or any other way
-
Hi, i want to read data from the source file of 3rd party website. The page is not in my control. Here i need to do two things. a. I just read the html content of that page in to string first b. and later i want to retrive some specific data from that string. the first option is ok. The second option i am not getting how to retive the data.
<tr>
<th>First Name</th>
<td width="100%"><input name="p_first_name" type="text" id="f-first-name" value="JEAN" /></td>
</tr>
<tr class="tr-back">
<th class="tr-back">Last Name</th>
<td><input name="p_last_name" type="text" id="f-last-name" value="AAREN" /></td>
</tr>
<tr>
<th>Occupation</th>
<td width="100%"><input name="o_occ" type="text" id="f-occ" value="UNKNOWN" /></td>
</tr>In the above code i want to retrive the values first name, middle name and lastname. i.e JEAN, AAREN, UNKNOWN Can any one help me how to retrive this code once reading all this html in to string..? or any other way
If you are sure that the resultant string is in valid XML format, just load it to
XmlDocument
and use XPath to get the required values. Other option is to use regular expression and look for the text.Best wishes, Navaneeth
-
If you are sure that the resultant string is in valid XML format, just load it to
XmlDocument
and use XPath to get the required values. Other option is to use regular expression and look for the text.Best wishes, Navaneeth
how to load that string in to xmldocument?
G. Satish
-
how to load that string in to xmldocument?
G. Satish
Work with XmlDocument.LoadXml(string xml)[^] overload.
Best wishes, Navaneeth
-
Hi, i want to read data from the source file of 3rd party website. The page is not in my control. Here i need to do two things. a. I just read the html content of that page in to string first b. and later i want to retrive some specific data from that string. the first option is ok. The second option i am not getting how to retive the data.
<tr>
<th>First Name</th>
<td width="100%"><input name="p_first_name" type="text" id="f-first-name" value="JEAN" /></td>
</tr>
<tr class="tr-back">
<th class="tr-back">Last Name</th>
<td><input name="p_last_name" type="text" id="f-last-name" value="AAREN" /></td>
</tr>
<tr>
<th>Occupation</th>
<td width="100%"><input name="o_occ" type="text" id="f-occ" value="UNKNOWN" /></td>
</tr>In the above code i want to retrive the values first name, middle name and lastname. i.e JEAN, AAREN, UNKNOWN Can any one help me how to retrive this code once reading all this html in to string..? or any other way
If you place a wrapper to all the tr's it will load easily in XMLDocument / XDocument. Just take the table tag which wrap around all the entries. Use
XElement.Load(your html string)
to get the xml loaded. Now search the elements using Linq to XML. Cheers...Abhishek Sur **Don't forget to click "Good Answer" if you like this Solution.
My Latest Articles-->** Simplify Code Using NDepend
Basics of Bing Search API using .NET
Microsoft Bing MAP using Javascript