Esempio n. 1
0
 public static string CleanHtml(string html, string basehref, string rewritehref)
 {
     try
     {
         Html.HtmlReader r  = new Html.HtmlReader(html);
         StringWriter    sw = new StringWriter();
         Html.HtmlWriter w  = new Html.HtmlWriter(sw);
         if (!string.IsNullOrEmpty(basehref))
         {
             w.Options.BaseHref = new Uri(basehref);
         }
         if (!string.IsNullOrEmpty(rewritehref))
         {
             w.Options.RewriteHref = new Uri(rewritehref);
         }
         while (!r.EOF)
         {
             w.WriteNode(r, true);
         }
         w.Close();
         return(sw.ToString());
     }
     catch (Exception e)
     {
         return(e.Message);
     }
 }
Esempio n. 2
0
 public static string CleanHtml(string html, string basehref, string rewritehref)
 {
     try
     {
         Html.HtmlReader r = new Html.HtmlReader(html);
         StringWriter sw = new StringWriter();
         Html.HtmlWriter w = new Html.HtmlWriter(sw);
         if (!string.IsNullOrEmpty(basehref)) w.Options.BaseHref = new Uri(basehref);
         if (!string.IsNullOrEmpty(rewritehref)) w.Options.RewriteHref = new Uri(rewritehref);
         while (! r.EOF)
         {
             w.WriteNode(r, true);
         }
         w.Close();
         return sw.ToString();
     }
     catch (Exception e)
     {
         return e.Message;
     }
 }