次のコードは、与えられたHTMLのHREFとIMGを含むすべてのURIを絶対パスに変更するために使用されます
private static string converttoabsoluteurrs(string html、uri relativelocation){
ihtmldocument2 doc = new htmldocumentclass();
doc.write(new object [] {html});
doc.close();
foreach(doc.linksのihtmlanchorelementアンカー){
ihtmLelement要素=(ihtmlelement)アンカー。
string href =(string)element.getAttribute( "href"、2);
if(href!= null){
uri addr = new uri(relativelocation、href);
anchor.href = addr.absoluteuri;
}
}
foreach(doc.imagesのihtmlimgelement画像){
ihtmLelement要素=(ihtmlelement)画像;
string src =(string)element.getattribute( "src"、2);
if(src!= null){
uri addr = new uri(relativelocation、src);
image.src = addr.absoluteuri;
}
}
string ret = doc.body.innerhtml;
返品;
}