Relative to absolute paths in HTML (asp.net) -


i need create newsletters url. next:

  1. create webclient;
  2. use webclient's method downloaddata source of page in byte array;
  3. get string source-html byte array , set newsletter content.

but have troubles paths. elements' sources relative (/img/welcome.png) need absolute (http://www.mysite.com/img/welcome.png).

how can this?

best regards, alex.

one of possible ways resolve task use htmlagilitypack library.

some example (fix links):

webclient client = new webclient(); byte[] requesthtml = client.downloaddata(sourceurl); string sourcehtml = new utf8encoding().getstring(requesthtml);  htmldocument htmldoc = new htmldocument(); htmldoc.loadhtml(sourcehtml);  foreach (htmlnode link in htmldoc.documentnode.selectnodes("//a[@href]")) {     if (!string.isnullorempty(link.attributes["href"].value))     {         htmlattribute att = link.attributes["href"];         att.value = this.absoluteurlbyrelative(att.value);     } } 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -