2
HTML 민첩성 팩을 사용하는 코드가 있습니다. 내가 뭘 하려는지, html 콘텐츠의 모든 링크를 대체합니다.HTML 민첩성 팩키지 링크 바꾸기
예를 들면 : 나는 모든 링크를 열거 할 수 있으며, 그 값을 얻을 수 있습니다
http://oldserver/Documents/1.pdf
http://newserver/Documents/2.pdf
에 대체합니다하지만 난 doc.Save()를 수행 할 때 원래의 HTML 소스를 저장 . 업데이트 된 html이 아닙니다. 어떻게하면 HtmlDocument에서 업데이트 된 HTML을 얻을 수 있습니다.
private string FixHyperlinks(string contentHtml, SPWeb web)
{
TextReader reader = new StringReader(contentHtml);
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.Load(reader);
List<string> hrefTags = new List<string>();
foreach (HtmlNode link in doc.DocumentNode.SelectNodes("//a[@href]"))
{
HtmlAttribute att = link.Attributes["href"];
att.Value = RepairHyperlinkAddress(att.Value, web);
}
MemoryStream memoryStream = new MemoryStream();
doc.Save(memoryStream);
memoryStream.Seek(0, System.IO.SeekOrigin.Begin);
StreamReader streamReader = new StreamReader(memoryStream);
string result = streamReader.ReadToEnd();
return result;
}
Actuallymy 문제가되지 않습니다. 나는 의도적으로 href 만한다. – ozdogan
그러면 우리는 일을 더 확인할 수 있도록 html을 게시해야합니다. –