Since we need to use C# to process related operations in I recently, we have accumulated some code. The following code is an example of generating a dom treeview from the html code:
//The process will be called recursively
//dom_node is the current html dom node
//tree_node is the node of the currently inserted tree
private void insertdomnodes(ihtmldomnode parentnode,treenode tree_node)
{
int sibing=0;//The order of the current nodes between sibling nodes is separated by ","
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);
}