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

首頁 > 編程 > HTML > 正文

C#中從HTML生成DOM TreeView的代碼

2024-08-26 00:15:35
字體:
來源:轉載
供稿:網友

由于最近需要使用c#處理ie的相關操作,因此積累了一些代碼,下面的代碼是從html代碼中生成dom treeview的例子:


//該過程將被遞歸調用
  //dom_node是當前的html dom節點
  //tree_node是當前插入樹的結點
  private void insertdomnodes(ihtmldomnode parentnode,treenode tree_node)
  {
  
   int sibing=0;//當前結點在兄弟結點之間的順序,所有的結點之間通過","隔開
   if(parentnode.haschildnodes())
   {
    //level++;
    //pathstring = pathstring +","+ level;
    ihtmldomchildrencollection allchild = (ihtmldomchildrencollection)parentnode.childnodes;
    int length = allchild.length;
    for(int i=0;i<length;i++)
    {
     string instring = pathstring;
     instring = instring +","+ sibing++;
     ihtmldomnode child_node = (ihtmldomnode)allchild.item(i);
     treenode tempnode = tree_node.nodes.add(child_node.nodename +"_"+instring);
     //string tmp =
     insertdomnodes(child_node,tempnode);
     pathstring = instring;
    }
   }
  }
  private void evipsbrowser_documentcomplete(object sender, axshdocvw.dwebbrowserevents2_documentcompleteevent e)
  {
   pathstring ="0";
   level = 0;
   domtreeview.nodes.clear();
   ihtmldocument3 htmldocument =(ihtmldocument3)evipsbrowser.document;
   ihtmldomnode rootdomnode = (ihtmldomnode)htmldocument.documentelement;
  
   treenode root = domtreeview.nodes.add("html"+"_"+pathstring);
   insertdomnodes(rootdomnode,root);
  }

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 包头市| 康保县| 互助| 屏南县| 陵水| 八宿县| 卢龙县| 桂阳县| 玛曲县| 富川| 邯郸市| 剑河县| 黔江区| 武陟县| 濮阳县| 塘沽区| 德昌县| 万安县| 班玛县| 汪清县| 凉城县| 潮安县| 洛川县| 鹿泉市| 鄂托克旗| 延津县| 兰州市| 龙口市| 逊克县| 凤台县| 孙吴县| 林周县| 常德市| 景德镇市| 安溪县| 绥江县| 志丹县| 甘肃省| 江津市| 淮安市| 阿尔山市|