国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 編程 > HTML > 正文

C#下從HTML文件生成DOM樹

2024-08-26 00:15:38
字體:
供稿:網(wǎng)友

  由于最近需要使用c#進行ie的相關(guān)編程,因此特整理出相應(yīng)的代碼出來,下面的代碼是訪問html,并生成treeview dom書的代碼:

private void insertdomnodes(ihtmldomnode parentnode,treenode tree_node)
  {
   if(parentnode.haschildnodes())
   {
    ihtmldomchildrencollection allchild = (ihtmldomchildrencollection)parentnode.childnodes;
    int length = allchild.length;

    for(int i=0;i<length;i++)
    {
     ihtmldomnode child_node = (ihtmldomnode)allchild.item(i);
     treenode tempnode = tree_node.nodes.add(child_node.nodename);
     insertdomnodes(child_node,tempnode);
    }
   }
  }
  //將domnode插入

  private void evipsbrowser_documentcomplete(object sender,  axshdocvw.dwebbrowserevents2_documentcompleteevent e)
  {
   domtreeview.nodes.clear();
   ihtmldocument3 htmldocument =(ihtmldocument3)evipsbrowser.document;
   ihtmldomnode rootdomnode = (ihtmldomnode)htmldocument.documentelement;
   
   treenode root = domtreeview.nodes.add("html");
   insertdomnodes(rootdomnode,root);
  }

發(fā)表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發(fā)表
主站蜘蛛池模板: 临湘市| 前郭尔| 青冈县| 云龙县| 高陵县| 旅游| 新宁县| 天峨县| 周至县| 根河市| 泗水县| 寿宁县| 浦东新区| 襄垣县| 湘西| 洪湖市| 新巴尔虎左旗| 留坝县| 太康县| 吴江市| 理塘县| 龙井市| 晋中市| 黄平县| 涿州市| 平和县| 四川省| 明星| 来安县| 蓬莱市| 哈密市| 南投市| 白沙| 长武县| 湘西| 甘肃省| 嘉兴市| 屏边| 湘乡市| 和静县| 嘉定区|