Rog*_*Far 2 c# webbrowser-control
我有一个webbrowser控件,我导航到包含此html的URL:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="content-type" content="text/html;charset=utf-8" />
<title></title>
</head>
<body marginheight="60" topmargin="60">
<p align="center"><img src="nocontent.jpg" alt="" height="434" width="525" border="0" /></p>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
但是,当我使用此代码获取源代码时:
HTMLDocument objHtmlDoc = (HTMLDocument)browser.Document.DomDocument;
string pageSource = objHtmlDoc.documentElement.innerHTML;
Console.WriteLine(pageSource);
Run Code Online (Sandbox Code Playgroud)
这是结果:
<HEAD><TITLE></TITLE>
<META content=text/html;charset=utf-8 http-equiv=content-type></HEAD>
<BODY topMargin=60 marginheight="60">
<P align=center><IMG border=0 alt="" src="nocontent.jpg" width=525 height=434></P></BODY>
Run Code Online (Sandbox Code Playgroud)
这对于进一步处理没有好处,我怎样才能确保它显示与我右键单击并选择"查看源"时相同的来源?