A
alessio211734
I trying to read a xml file and to fill a treeview with xml data.
The function code is used to fill a treeview but it's very very slow.
void PopulateXmlTreeView(XmlNode xnode,TreeNode tnode)
{
if (xnode.ChildNodes.Count>0)
{
//foreach (XmlNode xN in xnode.ChildNodes)
for (int i=0;i<xnode.ChildNodes.Count;i++)
{
XmlNode xN=xnode.ChildNodes;
TreeNode t=tnode.Nodes.Add(" ");
if (!(xN is System.Xml.XmlText))
t.Text+=xN.Name;
if (xN.Attributes!=null)
{
for (int j=0;j<xN.Attributes.Count;j++)
{
t.Text+=" ("+xN.Attributes.Item(j).Name;
t.Text+="= "+xN.Attributes.Item(j).Value+ ")";
//XmlAttributeCollection xN.Attributes.Count
//if (xN.Attributes!=null) t.Text=xN.Attributes.tex;
}
}
if (xN.Value!=null) t.Text+=" "+xN.Value;
PopulateXmlTreeView(xN,t);
}
}
}
The function code is used to fill a treeview but it's very very slow.
void PopulateXmlTreeView(XmlNode xnode,TreeNode tnode)
{
if (xnode.ChildNodes.Count>0)
{
//foreach (XmlNode xN in xnode.ChildNodes)
for (int i=0;i<xnode.ChildNodes.Count;i++)
{
XmlNode xN=xnode.ChildNodes;
TreeNode t=tnode.Nodes.Add(" ");
if (!(xN is System.Xml.XmlText))
t.Text+=xN.Name;
if (xN.Attributes!=null)
{
for (int j=0;j<xN.Attributes.Count;j++)
{
t.Text+=" ("+xN.Attributes.Item(j).Name;
t.Text+="= "+xN.Attributes.Item(j).Value+ ")";
//XmlAttributeCollection xN.Attributes.Count
//if (xN.Attributes!=null) t.Text=xN.Attributes.tex;
}
}
if (xN.Value!=null) t.Text+=" "+xN.Value;
PopulateXmlTreeView(xN,t);
}
}
}