国产探花免费观看_亚洲丰满少妇自慰呻吟_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);
  }

 

發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 林西县| 尼玛县| 来宾市| 贵定县| 博罗县| 抚顺市| 镇赉县| 厦门市| 来安县| 梁河县| 富宁县| 宁城县| 静宁县| 车致| 湟中县| 轮台县| 晴隆县| 安顺市| 青州市| 赞皇县| 秦安县| 方城县| 丰县| 秀山| 长乐市| 威信县| 新和县| 阿尔山市| 哈巴河县| 乌鲁木齐市| 利川市| 乐昌市| 新安县| 宿松县| 莱阳市| 西乌| 天门市| 淮阳县| 长葛市| 河源市| 太湖县|