O código a seguir é usado para alterar todos os URI, incluindo HREF e IMG no HTML fornecido para caminhos absolutos
String estática privada Converttoabsoluteurls (String html, URI RelativleClation) {
ihtmldocument2 doc = new htmldocumentClass ();
doc.Write (novo objeto [] {html});
doc.close ();
foreach (âncora ihtmlanchorElement em doc.links) {
IHTMLELEMENT Element = (ihtmlelement) âncora;
string href = (string) element.getAttribute ("href", 2);
if (href! = null) {
URI addr = novo URI (Relativivelocation, href);
anchor.href = addr.absoluteuri;
}
}
foreach (imagem ihtmlimgElement em doc.images) {
IHTMLELEMENT Element = (ihtmlelement) imagem;
string src = (string) element.getAttribute ("src", 2);
if (src! = null) {
URI addr = novo URI (Relativivelocation, SRC);
image.src = addr.absoluteuri;
}
}
string ret = doc.body.innerhtml;
retornar retorno;
}