日期:2014-05-20  浏览次数:20497 次

【分享】dhtml.net 仿javascript访问HTML文档
相信很多朋友都为解析HTML源码犯过愁,在社区里也经常看到有人提此类问题,

今天工作少,索性做了个解析HTML文档的通用组件,用法如下:

string url = "http://www.baidu.com/";//此处可以是一个URL,也可以是一段HTML字符串

Document doc = new Document(url);

Console.WriteLine(doc.Title);

Console.WriteLine(doc.GetElementById("u").InnerHTML);

输出结果:

百度一下,你就知道

<a href="http://passport.baidu.com/?login&tpl=mn">登录</a>

源码下载:http://www.cnopenblog.com/upload/Dhtml.net-src(1.0).rar

更多:http://blog.csdn.net/sq_zhuyi/archive/2010/06/21/5684520.aspx


------解决方案--------------------
好东西
------解决方案--------------------
为什么要仿javascript呢.
.net不是有 XML 解析方法么.
------解决方案--------------------
强!顶!
------解决方案--------------------
试过别的网页没?

------解决方案--------------------

------解决方案--------------------
Java code
try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException event){System.out.println(""+event);}
try{
            con=DriverManager.getConnection("jdbc:odbc:lpf", strUserId,strPassword);
            sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
            rs=sql.executeQuery("select * from dstudent where sno='"+jTextField1.getText()+"'");
catch(SQLException ee){
                JOptionPane.showMessageDialog(this, "学号不存在或输入错误", "错误", JOptionPane.WARNING_MESSAGE);
                System.out.println(ee);
            }

------解决方案--------------------
Java codetry { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException event){System.out.println(""+event);}
try{con=DriverManager.getConnection("jdbc:odbc:lpf", strUserId,strPassword);
sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
rs=sql.executeQuery("select * from dstudent where sno='"+jTextField1.getText()+"'");
catch(SQLException ee)
{ JOptionPane.showMessageDialog(this, "学号不存在或输入错误", "错误", JOptionPane.WARNING_MESSAGE);
System.out.println(ee); }

------解决方案--------------------
Java code
try { Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");}
catch(ClassNotFoundException event){System.out.println(""+event);}
try{con=DriverManager.getConnection("jdbc:odbc:lpf", strUserId,strPassword);
  sql=con.createStatement(ResultSet.TYPE_SCROLL_SENSITIVE,ResultSet.CONCUR_READ_ONLY);
  rs=sql.executeQuery("select * from dstudent where sno='"+jTextField1.getText()+"'");
catch(SQLException ee)
{ JOptionPane.showMessageDialog(this, "学号不存在或输入错误", "错误", JOptionPane.WARNING_MESSAGE);
  System.out.println(ee); }

------解决方案--------------------
不错。
------解决方案--------------------
好东西
------解决方案--------------------
阿尔法而发而发而发而发而发而发而未发而为
------解决方案--------------------
好东西学习了
------解决方案--------------------