"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
public class MyProvider : System.Web.Hosting.VirtualPathProvider
{ int i = 0;
public static void AppInitialize()
{
MyProvider fileProvider = new MyProvider();
System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(fileProvider);
}
public override bool FileExists(string virtualPath)
{
if (virtualPath.EndsWith("YourVirtualPath.aspx"))
return true;
else
return Previous.FileExists(virtualPath);
}
public override System.Web.Hosting.VirtualFile GetFile(string virtualPath)
{
if (virtualPath.EndsWith("YourVirtualPath.aspx"))
{
string s = "http://www.bing.com/search?q=Searching+Text+Box+In+Bing+Site&go=&form=QBRE&qs=n";//Default
if (HttpContext.Current.Application["url"] != null)
s = HttpContext.Current.Application["url"].ToString();
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(s);
HttpWebResponse respons;
respons = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(respons.GetResponseStream());
string contents = reader.ReadToEnd().Replace("<input", "<input runat=\"server\""); contents = System.Text.RegularExpressions.Regex.Replace(contents,"<table",new System.Text.RegularExpressions.MatchEvaluator(ReplaceIds),System.Text.RegularExpressions.RegexOptions.IgnoreCase);
return new MyVirtualFile(virtualPath, contents);
}
else
return Previous.GetFile(virtualPath);
There is no Literal in HTML instead it is ASP.NET Control which content paste as it is as I know.
"And whoever is removed away from the Fire and admitted to Paradise, he indeed is successful." (The Holy Quran)
Excellent Windows VPS Hosting Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Hua-Jun Li -...
All-Star
75950 Points
5608 Posts
Re: Get viewsource data from HTML and yet set regular expression to ignore <TD></TD>
Nov 02, 2009 03:31 AM|LINK
Hi Edwin_Pro_Net,
You can use the following method to find all the TD tag, and remove the content from the html.
Then you can eliminate that.
Please check the following code:
private string RemoveTDTag(string result)
{
Regex chr = new Regex(@"<TD[^>]*>([^<])+</TD>", RegexOptions.IgnoreCase);
for (Match m = chr.Match(result); m.Success; m = m.NextMatch())
{
result = result.Remove(groups[0].ToString());
}
return result;
}
If you have any feedback about my replies, please contact msdnmg@microsoft.com.
Microsoft One Code Framework
Edwin_Pro_Ne...
Member
12 Points
60 Posts
Re: Get viewsource data from HTML and yet set regular expression to ignore <TD></TD>
Nov 02, 2009 03:45 AM|LINK
I just remove all the <TR>, the <TD> only important perhaps not to ignore,
becoz i need to go to certain <TD> in order to get the data....
do u got the way to how to solve it, if i need to take only circled data below.....
i only know go to no. 6th, 7th, 8th TD to get like picture below, but don't know how to get the exact circled value which i get from
html paste to textbox.............
thanks
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Get viewsource data from HTML and yet set regular expression to ignore <TD></TD>
Nov 02, 2009 06:39 AM|LINK
The Sample Code is uploaded here
http://www.esnips.com/doc/5fd12aad-cb74-48b6-aa47-b5b4abe505c3/DynamicPage
There is some modification in the Code,
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Edwin_Pro_Ne...
Member
12 Points
60 Posts
Re: Get viewsource data from HTML and yet set regular expression to ignore <TD></TD>
Nov 02, 2009 08:12 AM|LINK
for the <input<input runat="server"
i change to literal coz the input size not available for large value
want to ask if table don have the table id, then how ?
since i grab from the view source............
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Get viewsource data from HTML and yet set regular expression to ignore <TD></TD>
Nov 02, 2009 08:20 AM|LINK
Please explain clearly and with example
contents = contents.Replace("<table", "<table id=\"tablename\" runat=\"server\"");
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD
Edwin_Pro_Ne...
Member
12 Points
60 Posts
Re: Get viewsource data from HTML and yet set regular expression to ignore <TD></TD>
Nov 02, 2009 08:53 AM|LINK
Edwin_Pro_Ne...
Member
12 Points
60 Posts
Re: Get viewsource data from HTML and yet set regular expression to ignore <TD></TD>
Nov 02, 2009 08:54 AM|LINK
do you understand my problem now ?
hopefully u can help it...
thanks
Edwin_Pro_Ne...
Member
12 Points
60 Posts
Re: Get viewsource data from HTML and yet set regular expression to ignore <TD></TD>
Nov 02, 2009 09:02 AM|LINK
since the find control("jjj") that i already changed oso cant get access for the table
Edwin_Pro_Ne...
Member
12 Points
60 Posts
Re: Get viewsource data from HTML and yet set regular expression to ignore <TD></TD>
Nov 02, 2009 09:25 AM|LINK
There were so many table in the html source file, how do i identify this table
below which i hightlighted red color, that i want to get the source..........
thanks
imran_ku07
All-Star
45815 Points
7698 Posts
MVP
Re: Get viewsource data from HTML and yet set regular expression to ignore <TD></TD>
Nov 02, 2009 09:31 AM|LINK
Just a small changes in Bold,
public class MyProvider : System.Web.Hosting.VirtualPathProvider
{
int i = 0;
public static void AppInitialize()
{
MyProvider fileProvider = new MyProvider();
System.Web.Hosting.HostingEnvironment.RegisterVirtualPathProvider(fileProvider);
}
public override bool FileExists(string virtualPath)
{
if (virtualPath.EndsWith("YourVirtualPath.aspx"))
return true;
else
return Previous.FileExists(virtualPath);
}
public override System.Web.Hosting.VirtualFile GetFile(string virtualPath)
{
if (virtualPath.EndsWith("YourVirtualPath.aspx"))
{
string s = "http://www.bing.com/search?q=Searching+Text+Box+In+Bing+Site&go=&form=QBRE&qs=n";//Default
if (HttpContext.Current.Application["url"] != null)
s = HttpContext.Current.Application["url"].ToString();
HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(s);
HttpWebResponse respons;
respons = (HttpWebResponse)request.GetResponse();
StreamReader reader = new StreamReader(respons.GetResponseStream());
string contents = reader.ReadToEnd().Replace("<input", "<input runat=\"server\"");
contents = System.Text.RegularExpressions.Regex.Replace(contents,"<table",new System.Text.RegularExpressions.MatchEvaluator(ReplaceIds),System.Text.RegularExpressions.RegexOptions.IgnoreCase);
return new MyVirtualFile(virtualPath, contents);
}
else
return Previous.GetFile(virtualPath);
}
private string ReplaceIds(System.Text.RegularExpressions.Match input)
{
i++;
return "<table id=\"jjj"+i+"\" runat=\"server\"";
}
}
There is no Literal in HTML instead it is ASP.NET Control which content paste as it is as I know.
Excellent Windows VPS Hosting
Imran Baloch MVP, MVB, MCP, MCTS, MCPD