Home > other >  How to read and search the content from .asp file using C#.net code
How to read and search the content from .asp file using C#.net code

Time:07-05

I have some .asp files and I want to read the content file like we did for xmldocument.

For an example:- suppose my .asp file contents following code:-

  <DIV id=DIV_CI_0084  style="LEFT: 677px; TOP: 361px; 
    position:absolute">0084</DIV>

   <DIV id=DIV_BF_0202  style="LEFT: 393px; TOP: 313px; 
   position:absolute">202</DIV>
   <DIV id=DIV_SHO_0202  style="LEFT: 715px; TOP: 296px; 
   position:absolute">SHO 0202</DIV>
   <DIV id=DIV_HCO_202  style="LEFT: 657px; TOP: 300px; 
   position:absolute">HCO 202</DIV>
  <DIV id=DIV_BF_0203  style="LEFT: 769px; TOP: 313px; 
  position:absolute">203</DIV>
  <DIV id=DIV_BF_0204  style="LEFT: 828px; TOP: 313px; 
  position:absolute">204</DIV>
  <DIV id=DIV_BF_0205  style="LEFT: 882px; TOP: 313px; 
  position:absolute">205</DIV>
  <DIV id=DIV_BF_0206  style="LEFT: 971px; TOP: 319px; 
  position:absolute">206</DIV>
  <DIV id=DIV_BF_0207  style="LEFT: 1075px; TOP: 314px; 
  position:absolute">207</DIV>
  <DIV id=DIV_BF_0208  style="LEFT: 1144px; TOP: 312px; 
  position:absolute">208</DIV>
  <DIV id=DIV_BF_0209  style="LEFT: 1147px; TOP: 255px; 
  position:absolute">209</DIV>
  <DIV id=DIV_BF_0210  style="LEFT: 1147px; TOP: 154px; 
  position:absolute">210</DIV>

Now I want to read node id=DIV_BF_0208 and extract the data style and position.

If we have xaml file then we can use concept of child node, attribute concept.

Do we have similar concept or covert it into excel file then read it.

I need that to develop some tool using c#.net

CodePudding user response:

My strategy would be to fix it, lingering 20yr old asp files in your solution isn't going to look very modern. Instead put all the entries in a Database, even a NoSQL dB.

I'm guessing this asp site is not online anymore and you have a finite set of asp files to scan (if not wget the website).

Extract INSERT SQL Statements from raw asp files using HtmlAgilityPack:

var htmlDoc = new HtmlDocument();
htmlDoc.LoadHtml(html);

foreach(HtmlNode div in htmlDoc.DocumentNode.SelectNodes("//div[contains(@class,'Horiz_Small')]"))
{
  sb.Append("INSERT INTO Table (Cols) VALUES ");
  sb.AppendLine(div.InnerText);
}
File.WriteAllText("C:\\Path\\inserts1.sql", sb.ToString());
  • Related