第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

遞歸,將帶有屬性的XML文件解析為TreeView c#

遞歸,將帶有屬性的XML文件解析為TreeView c#

C#
胡說叔叔 2019-06-26 14:49:43
遞歸,將帶有屬性的XML文件解析為TreeView c#我目前正在進(jìn)行一個(gè)項(xiàng)目,在這個(gè)項(xiàng)目中,應(yīng)用程序?qū)⒔邮誜ML文件,并將其顯示在C#中的TreeView中。我正在使用VisualStudio 10編寫這段代碼。我不能限制顯示屬性的次數(shù)。我使用一個(gè)foreach循環(huán)遍歷它所擁有的每個(gè)屬性并顯示它,但是它只對(duì)它在節(jié)點(diǎn)下的每個(gè)子節(jié)點(diǎn)顯示一次屬性。如何修改此代碼,使其只顯示屬性一次?using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using System.Xml;namespace xmlToTreeview{     public partial class Form1 : Form     {         string samplePath = Application.StartupPath + @"\\sample.xml";         public Form1()         {             InitializeComponent();             DisplayTreeView(samplePath);         }         private void DisplayTreeView(string pathname)         {             try             {                 // SECTION 1. Create a DOM Document and load the XML data into it.                 XmlDocument dom = new XmlDocument();                 dom.Load(pathname);                 // SECTION 2. Initialize the TreeView control.                 treeView1.Nodes.Clear();                 treeView1.Nodes.Add(new TreeNode(dom.DocumentElement.Name));                 TreeNode tNode = new TreeNode();                 tNode = treeView1.Nodes[0];                 // SECTION 3. Populate the TreeView with the DOM nodes.                 AddNode(dom.DocumentElement, tNode);             }             catch (XmlException xmlEx)             {                 MessageBox.Show(xmlEx.Message);             }             catch (Exception ex)             {                 MessageBox.Show(ex.Message);             }         }         private void AddNode(XmlNode inXmlNode, TreeNode inTreeNode)         {             XmlNode xNode;             TreeNode tNode;             XmlNodeList nodeList;             int i;             // Loop through the XML nodes until the leaf is reached.             // Add the nodes to the TreeView during the looping process.
查看完整描述

2 回答

  • 2 回答
  • 0 關(guān)注
  • 748 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)