private void addNextLevelNodes(MyTreeNode tParentNode) { String xp = tParentNode.Tag.ToString(); if (xp == null) { return; } XmlNode xParentNode = evalXPath(dom, xp); // Add the nodes to the TreeView during the looping process. if (xParentNode != null && xParentNode.HasChildNodes) { if ("page".Equals(xParentNode.Name)) { return; // don't go deeper that the "page" element... } XmlNodeList nodeList = xParentNode.ChildNodes; int size = nodeList.Count - 1; for (int i = 0; i <= size; i++) { XmlNode xNode = xParentNode.ChildNodes[i]; if (xNode.NodeType == XmlNodeType.Element) { MyTreeNode tnode = new MyTreeNode(getAttribute(xNode, "Title"), getNodeType(xNode)); tnode.Tag = getXPath(xNode); tParentNode.Nodes.Add(tnode); MyTreeNode fakeNode = new MyTreeNode("loading...", 1); tnode.Nodes.Add(fakeNode); } } } }
private void AddNode(XmlNode inXmlNode, MyTreeNode inTreeNode) { XmlNode xNode; MyTreeNode tNode; XmlNodeList nodeList; int i; Console.Out.WriteLine("Date " + System.DateTime.Now + " tree.node = " + inTreeNode); // Loop through the XML nodes until the leaf is reached. // Add the nodes to the TreeView during the looping process. if (inXmlNode.HasChildNodes) { nodeList = inXmlNode.ChildNodes; int size = nodeList.Count - 1; for (i = 0; i <= size; i++) { xNode = inXmlNode.ChildNodes[i]; if (xNode.NodeType == XmlNodeType.Element) { String name = getAttribute(xNode, "Title"); inTreeNode.Nodes.Add(new MyTreeNode(name, getNodeType(xNode))); tNode = (MyTreeNode)inTreeNode.Nodes[i]; AddNode(xNode, tNode); } } } else { inTreeNode.Text = getAttribute(inXmlNode, "Title"); } }