| 软件 | C# 读取xml文件的示例 |
| 内容 |
C# 读取xml文件的示例,核心代码如下所示: 【核心代码】using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using System.Xml;
using System.Collections;
namespace eg107
{
? ? public partial class Form1 : Form
? ? {
? ? ? ? public Form1()
? ? ? ? {
? ? ? ? ? ? InitializeComponent();
? ? ? ? }
? ? ? ? private void button1_Click(object sender, EventArgs e)
? ? ? ? {
? ? ? ? ? ? Hashtable Htemp = SelectXml("F:\\VS2012\\ReadXML\\BroadCastInfo.xml");
? ? ? ? ? ? richTextBox1.Text ?= string.Format("HashTale Count = {0} " "\n",Htemp.Count);
? ? ? ? ? ? IDictionaryEnumerator IDEum = Htemp.GetEnumerator();
? ? ? ? ? ? while (IDEum.MoveNext())
? ? ? ? ? ? {
? ? ? ? ? ? ? ? richTextBox1.Text ?= IDEum.Key;
? ? ? ? ? ? ? ? richTextBox1.Text ?= IDEum.Value ?"\n";
? ? ? ? ? ? }
? ? ? ? }
? ? ? ? static Hashtable SelectXml(string url)
? ? ? ? {
? ? ? ? ? ? Hashtable HTable = new Hashtable();
? ? ? ? ? ? XmlDocument doc = new XmlDocument();
? ? ? ? ? ? doc.Load(url);
? ? ? ? ? ? XmlNodeList xnl = doc.SelectSingleNode("BCastInfo").ChildNodes;
? ? ? ? ? ? string key = "";
? ? ? ? ? ? string value = "";
? ? ? ? ? ? foreach (XmlNode xn in xnl)
? ? ? ? ? ? {
? ? ? ? ? ? ? ? XmlElement xe = (XmlElement)xn;
? ? ? ? ? ? ? ? if (xe.Name == "DInfo")
? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? XmlNodeList xnlChild1 = xn.ChildNodes;
? ? ? ? ? ? ? ? ? ? foreach (XmlNode xnchild in xnlChild1)
? ? ? ? ? ? ? ? ? ? {
? ? ? ? ? ? ? ? ? ? ? ? XmlElement xeChild1 = (XmlElement)xnchild;
? ? ? ? ? ? ? ? ? ? ? ? if (xeChild1.Name == "Address")
? ? ? ? ? ? ? ? ? ? ? ? ? ? key = xeChild1.InnerText;
? ? ? ? ? ? ? ? ? ? ? ? else if (xeChild1.Name == "Name")
? ? ? ? ? ? ? ? ? ? ? ? ? ? value = xeChild1.InnerText;
? ? ? ? ? ? ? ? ? ? }
? ? ? ? ? ? ? ? ? ? HTable.Add(key, value);
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? ? ? return HTable;
? ? ? ? }
? ? }
} |
| 标签 | 读取,c#,XML |
| 缩略图 | ![]() |
| 软件名称 | C# 读取xml文件的示例 |
| 软件图标 | |
| 软件大小 | 0.007MB |
| 发布时间 | |
| 软件平台 | |
| 软件语言 | 简体中文 |
| 软件授权 | 免费软件 |
| 操作系统 | Windows平台 |
| 系统类型 | |
| 用户评分 | 3 |
| 软件版本 | |
| 官方网站 | |
| 官方网址 | |
| 软件截图 | |
| 软件总类 | 源码系统 |
| 软件大类 | 源码下载-软件开发-C#源码-c# 读取xml文件 |
| 软件小类 | C#源码 |
| 开发者 | |
| 主办单位名称 | |
| ICP备案名 | |
| 备案号 | |
| 使用年龄 | |
| 下载链接 | ![]() |
| 攻略教程 | |
| 详细介绍 | |
| 操控设备 | |
| 隐私政策 | |
| 查看权限 | |
| 敏感权限获取说明 | |
| 软件类型 | 国产软件 |
| 安全警示 | 适度休息有益身心健康,请勿长期沉迷于使用电脑或刷手机。 |
| 随便看 |
|
传承兰台文化,共同保存历史记忆!兰台网收藏软件、游戏、图片、图书、电影、电视剧等互联网档案,是免费和可借阅文本、电影、音乐等档案的数字图书馆。