0

ドキュメントプロパティにアクセスすると、xmlではなくコントロールが生成したHTMLを取得します。ドキュメントの「ソース」を保存するにはどうすればよいですか? (Web クライアントは使用できません)

4

1 に答える 1

0

あなたは元の道を持っていますよね?

string urlPath = wb.Url;

そこからソースをダウンロードしてみませんか?

private string GetSourceCode(string sourceUrl) {
   String url = String.Format(sourceUrl);

   WebClient client = new WebClient();
   client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 6.0;)"); // pass as Internet Explorer 7.0

   Stream data = client.OpenRead(url);
   StreamReader reader = new StreamReader(data);
   s = reader.ReadToEnd();
   data.Close();
   reader.Close();

   return s;
}

GetSourceCode() メソッドを使用すると、返された文字列にソース全体 (元のソース) が含まれます...それで必要なことを行います;)

string xmlSource = GetSourceCode(wb.Url);
于 2009-06-04T06:56:50.287 に答える