Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. want a help in the code...... [modified]

want a help in the code...... [modified]

Scheduled Pinned Locked Moved C#
htmlxmlhelpquestion
2 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    samidhas
    wrote on last edited by
    #1

    static void Main() { Application.Run(new Form1()); } private System.Windows.Forms.GroupBox grpbox; XPathDocument dom; XmlDocument doc; XPathNavigator nav; XPathExpression expr; XPathNodeIterator iterator; int cnt=0; Label lbl; TextBox txt; OpenFileDialog dlg; TreeNode newTreeNode,rootnode,parentnode; string text; int i; //int cnt = e.Node.GetNodeCount(false); //string filename; private void Form1_Load(object sender, System.EventArgs e) { //label1.Text = "File Path"; //label1.SetBounds(8, 8, 50, 20); //filename = Application.StartupPath + "\\Sample.xml"; //textBox1.Text= filename; //textBox1.SetBounds(64, 8, 256, 20); button1.Text = "Populate the TreeView with XML"; button1.SetBounds(8, 20, 200, 20); treeXml.Height = 600; treeXml.Width = 400; grpbox = new GroupBox(); grpbox.Height = 600; grpbox.Width = 400; grpbox.SetBounds(500, 2, 700, 600); grpbox.Visible = true; grpbox.Dock.Equals(Right); grpbox.Show(); this.Controls.Add(grpbox); //dom = new XPathDocument(dlg.FileName); } // it will acess the xml file into treeview private void ConvertXmlNodeToTreeNode(XmlNode xmlNode, TreeNodeCollection treeNodes) { TreeNode newTreeNode = treeNodes.Add(xmlNode.Name); switch (xmlNode.NodeType) { case XmlNodeType.ProcessingInstruction: case XmlNodeType.XmlDeclaration: newTreeNode.Text = "<?" + xmlNode.Name + " " + xmlNode.Value + "?>"; break; case XmlNodeType.Element: if (xmlNode.Name.ToLower().Equals("node") == true) { newTreeNode.Text = "<" + xmlNode.Attributes["label"].Value.ToString() + ">"; } else newTreeNode.Text = "<" + xmlNode.Name + ">"; break; case XmlNodeType.Attribute: newTreeNode.Text = xmlNode.Name; // newTreeNode.Text = "ATTRIBUTE: " + xmlNode.Name; break; case XmlNodeType.Text: case XmlNodeType.CDATA: newTreeNode.Text = xmlNode.Value; break; case XmlNodeType.Comment: newTreeNode.Text = "<!--" + xmlNode.Value + "-->"; break; } if (xmlNode.Attributes != null) { foreach (XmlAttribute attribute in xmlNode.Attributes) { ConvertXmlNodeToTreeNode(attribute, newTreeNode.Nodes); } } foreach (XmlNode childNode in xmlNode.ChildNodes) { ConvertXmlNodeToTreeNode(childNode, newTree

    G 1 Reply Last reply
    0
    • S samidhas

      static void Main() { Application.Run(new Form1()); } private System.Windows.Forms.GroupBox grpbox; XPathDocument dom; XmlDocument doc; XPathNavigator nav; XPathExpression expr; XPathNodeIterator iterator; int cnt=0; Label lbl; TextBox txt; OpenFileDialog dlg; TreeNode newTreeNode,rootnode,parentnode; string text; int i; //int cnt = e.Node.GetNodeCount(false); //string filename; private void Form1_Load(object sender, System.EventArgs e) { //label1.Text = "File Path"; //label1.SetBounds(8, 8, 50, 20); //filename = Application.StartupPath + "\\Sample.xml"; //textBox1.Text= filename; //textBox1.SetBounds(64, 8, 256, 20); button1.Text = "Populate the TreeView with XML"; button1.SetBounds(8, 20, 200, 20); treeXml.Height = 600; treeXml.Width = 400; grpbox = new GroupBox(); grpbox.Height = 600; grpbox.Width = 400; grpbox.SetBounds(500, 2, 700, 600); grpbox.Visible = true; grpbox.Dock.Equals(Right); grpbox.Show(); this.Controls.Add(grpbox); //dom = new XPathDocument(dlg.FileName); } // it will acess the xml file into treeview private void ConvertXmlNodeToTreeNode(XmlNode xmlNode, TreeNodeCollection treeNodes) { TreeNode newTreeNode = treeNodes.Add(xmlNode.Name); switch (xmlNode.NodeType) { case XmlNodeType.ProcessingInstruction: case XmlNodeType.XmlDeclaration: newTreeNode.Text = "<?" + xmlNode.Name + " " + xmlNode.Value + "?>"; break; case XmlNodeType.Element: if (xmlNode.Name.ToLower().Equals("node") == true) { newTreeNode.Text = "<" + xmlNode.Attributes["label"].Value.ToString() + ">"; } else newTreeNode.Text = "<" + xmlNode.Name + ">"; break; case XmlNodeType.Attribute: newTreeNode.Text = xmlNode.Name; // newTreeNode.Text = "ATTRIBUTE: " + xmlNode.Name; break; case XmlNodeType.Text: case XmlNodeType.CDATA: newTreeNode.Text = xmlNode.Value; break; case XmlNodeType.Comment: newTreeNode.Text = "<!--" + xmlNode.Value + "-->"; break; } if (xmlNode.Attributes != null) { foreach (XmlAttribute attribute in xmlNode.Attributes) { ConvertXmlNodeToTreeNode(attribute, newTreeNode.Nodes); } } foreach (XmlNode childNode in xmlNode.ChildNodes) { ConvertXmlNodeToTreeNode(childNode, newTree

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      How to get an answer to your question[^]

      Experience is the sum of all the mistakes you have done.

      1 Reply Last reply
      0
      Reply
      • Reply as topic
      Log in to reply
      • Oldest to Newest
      • Newest to Oldest
      • Most Votes


      • Login

      • Don't have an account? Register

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • World
      • Users
      • Groups