Étant donné que nous devons utiliser C # pour traiter les opérations connexes dans I récemment, nous avons accumulé du code. Le code suivant est un exemple de génération d'un Dom TreeView à partir du code HTML:
// Le processus sera appelé récursivement
// DOM_NODE est le nœud HTML DOM actuel
// arbre_node est le nœud de l'arbre actuellement inséré
INSTERDADODODES PRIVÉS (IHTMLDOMNODE PARENTNODODE, TREENODE Tree_Node)
{
int sibing = 0; // L'ordre des nœuds de courant entre les nœuds de frères et sœurs est séparé par ","
if (parentNode.haschildNodes ())
{
// Niveau ++;
// pathstring = pathstring + "," + niveau;
IhtmldomChildRencollection Allchild = (ihtmldomChildRencollection) parentNode.childNodes;
int length = allchild.length;
pour (int i = 0; i <longueur; i ++)
{
String instring = pathstring;
instruction = instruction + "," + sibing ++;
ihtmldomnode child_node = (ihtmldomnode) allchild.item (i);
Treenode tempnode = arbre_node.nodes.add (child_node.nodename + "_" + instruction);
// chaîne tmp =
insertDomNodes (child_node, tempnode);
pathstring = instruction;
}
}
}
private void evipsbrowser_DocumentComplete (expéditeur d'objet, axshdocvw.dwebbrowerevents2_documentcompleteevent e)
{
pathString = "0";
niveau = 0;
domtreeview.nodes.clear ();
ihtmlDocument3 htmlDocument = (ihtmlDocument3) evipsbrowser.Document;
ihtmldomnode rootDomnode = (ihtmldomnode) htmlDocument.DocumentElement;
Treenode root = domtreeview.nodes.add ("html" + "_" + pathstring);
insertDomNodes (rootdomnode, racine);
}