国产探花免费观看_亚洲丰满少妇自慰呻吟_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ā)表
主站蜘蛛池模板: 崇礼县| 乌兰察布市| 永平县| 鹿泉市| 鹰潭市| 白银市| 三亚市| 平顶山市| 沂源县| 英超| 柞水县| 惠来县| 阿巴嘎旗| 巩留县| 古丈县| 泊头市| 游戏| 永州市| 枣庄市| 德格县| 黎平县| 萍乡市| 土默特右旗| 双牌县| 彭泽县| 张家川| 皮山县| 普宁市| 嘉荫县| 木里| 甘洛县| 大洼县| 鄂托克旗| 新乡县| 理塘县| 兴和县| 蓝田县| 崇礼县| 北京市| 本溪| 杭锦旗|