Ejemplo 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);
     }
 }
 public static string Rewrite(string html, Uri baseuri)
 {
     HtmlReader r = new HtmlReader(html);
     StringWriter sw = new StringWriter();
     HtmlAbsoluteLinksWriter w = new HtmlAbsoluteLinksWriter(sw);
     w.BaseHref = baseuri;
     while (!r.EOF)
     {
         w.WriteNode(r, true);
     }
     w.Close();
     return sw.ToString();
 }
        public static string Rewrite(string html, Uri baseuri)
        {
            HtmlReader              r  = new HtmlReader(html);
            StringWriter            sw = new StringWriter();
            HtmlAbsoluteLinksWriter w  = new HtmlAbsoluteLinksWriter(sw);

            w.BaseHref = baseuri;
            while (!r.EOF)
            {
                w.WriteNode(r, true);
            }
            w.Close();
            return(sw.ToString());
        }
Ejemplo n.º 4
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;
     }
 }