"Daniel O'Connell" <on******@comcast.net> schreef in bericht
news:VS63b.277982$uu5.61641@sccrnsc04...
If it is xhtml, anyway, some HTML is not xml compliant and will likely
cause errors.
the mshtml DOM may be of use otherwise. (reference Microsoft.mshtml.dll in
your references dialog)
How do you do that with C#Builder?
I have done some programming with TreeViews and XML Documents:
private void showXmlNodeAtTreeNode(XmlNodeList xnl, TreeNode tn)
{
int i;
for (i = 0; i < xnl.Count; i++) // how many nodes are there in the XML
document?
{
XmlNode xn = xnl[i]; // take the next node
XmlNodeType nodeType = xn.NodeType; // determine its type
if (nodeType == XmlNodeType.Element) // is it an element?
{
tn.Nodes.Add("Element: " + xn.Name); // add its name in the tree view
showXmlNodeAtTreeNode(xn.ChildNodes, tn.Nodes[i]); // add the XML child
nodes to this node
} else
if (nodeType == XmlNodeType.Text) // is it text?
{
tn.Nodes.Add("Text: " + xn.InnerText); // yes? then add it to the node
}
}
}
private void parseButton_Click(object sender, System.EventArgs e)
{
XmlDocument xd = new XmlDocument();
xd.LoadXml(xmlBox.Text); // load the text from a MultiLine EditBox
xmlView.Nodes.Clear(); // clear the TreeView
xmlView.Nodes.Add("Start"); // add "Start" at the root of the tree.
showXmlNodeAtTreeNode(xd.ChildNodes, xmlView.Nodes[0]); // add the XML
child nodes to the first TreeView nodes, and do that using recursion.
}
It could word with HTML but it is very strict. A small HTML syntax error can
crash the program, because no exceptions are catched.
I do mention it, because other newbies have an idea:
- how an XML document is parsed;
- how the XML nodes are read;
- how the treeview nodes are programmed.
Hans Kamp.