C#中怎么从htm中读取数据

解决方案 »

  1.   

    你要读啥数据哦?
    可以用AJAX技术得到
        <script language="javascript" type="text/javascript">
        ……=document.getElementById("控件ID").value;
        </script>
    具体自己查
      

  2.   

    public class WebRequestGetExample
        {
            public static void Main ()
            {
                // Create a request for the URL. 
                WebRequest request = WebRequest.Create ("http://www.contoso.com/default.html");
                // If required by the server, set the credentials.
                request.Credentials = CredentialCache.DefaultCredentials;
                // Get the response.
                HttpWebResponse response = (HttpWebResponse)request.GetResponse ();
                // Display the status.
                Console.WriteLine (response.StatusDescription);
                // Get the stream containing content returned by the server.
                Stream dataStream = response.GetResponseStream ();
                // Open the stream using a StreamReader for easy access.
                StreamReader reader = new StreamReader (dataStream);
                // Read the content.
                string responseFromServer = reader.ReadToEnd ();
                // Display the content.
                Console.WriteLine (responseFromServer);
                // Cleanup the streams and the response.
                reader.Close ();
                dataStream.Close ();
                response.Close ();
            }
        }
      

  3.   

    可以把数据加载到xmldocument对象里,但前提是html文件中的标签要象xml一样成对出现
      

  4.   

    see http://www.cnblogs.com/dragon/archive/2005/06/15/174946.html
    maybe it can help you!
      

  5.   

    直接作文本解析也不错。我一般先用HTML Tidy整理一下,然后解析,这样可以消除一些HTML中间的问题。
      

  6.   

    我从网上看到HTML Tidy这个技术了,可是不会用,还得麻烦各位再说详细点,谢谢!