0

I have one XML file that look like this:- XML file

I want to display it like this image:- Required output

How can I re-format/populate the output for each node like in the image? I have tried populate treeview from XML using below code:

private void AddNode(XmlNode inXmlNode, TreeNode inTreeNode)
    {
        if (inXmlNode is XmlElement)
        {
           foreach (var att in inXmlNode.Attributes.Cast<XmlAttribute>().Where(a => !a.IsNamespaceDeclaration()))
            {
                inTreeNode.Text = FirstCharToUpper(att.Name) + ": " + att.Value;
            }

            foreach (XmlNode xNode in inXmlNode.ChildNodes)
            {
                var tNode = inTreeNode.Nodes[inTreeNode.Nodes.Add(new TreeNode(xNode.Name))];
                AddNode(xNode, tNode);
            }
        }
        else
        {
            inTreeNode.Text = (inXmlNode.OuterXml).Trim();
        }
        treeViewMenu.ExpandAll();
    }

And I get the output like this:- Tree view

Already refer to this post: Replacing the innertext of an Xml node/element

However I still unclear about the flow or at which part I have to change.

ProgrammingLlama
  • 36,677
  • 7
  • 67
  • 86
HNA
  • 107
  • 2
  • 14

0 Answers0