16,555
社区成员
发帖
与我相关
我的任务
分享
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; ///这个必须加
namespace XMLGETEST
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
listBox1.Items.Clear();
XmlDocument doc = new XmlDocument();
doc.Load("D:\\C#\\XMLTEST.xml");//文件路径
XmlElement root = null;
root = doc.DocumentElement;
XmlNodeList listNodes = null;
listNodes = root.SelectNodes("/root/body/vehispara/Data");
foreach (XmlNode node in listNodes)
{
listBox1.Items.Add(node.InnerText.ToString());
}
}
}
}