iis服务器助手广告广告
返回顶部
首页 > 资讯 > 后端开发 > 其他教程 >C#实现利用Linq操作Xml文件
  • 752
分享到

C#实现利用Linq操作Xml文件

C#Linq操作XmlC#操作XmlC#LinqXml 2022-12-29 09:12:24 752人浏览 独家记忆
摘要

目录实践过程效果代码实践过程 效果 代码 public partial class FORM1 : Form { public Form1() {

实践过程

效果

代码

public partial class FORM1 : Form
{
    public Form1()
    {
        InitializeComponent();
    }

    static string strPath = "Employee.xml";
    static string strID = "";

    //窗体加载时加载XML文件
    private void Form1_Load(object sender, EventArgs e)
    {
        if (File.Exists(strPath))
        {
            groupBox1.Enabled = false;
            getXmlInfo();
        }
        else
            groupBox1.Enabled = true;
    }

    //创建XML文件
    private void button1_Click(object sender, EventArgs e)
    {
        XDocument doc = new XDocument(
            new XDeclaration("1.0", "utf-8", "yes"),
            new XElement(textBox1.Text,
                new XElement(textBox2.Text, new XAttribute(textBox3.Text, textBox10.Text),
                    new XElement(textBox4.Text, textBox5.Text),
                    new XElement(textBox6.Text, textBox7.Text),
                    new XElement(textBox8.Text, textBox9.Text))
                )
            );
        doc.Save(strPath);
        groupBox1.Enabled = false;
        getXmlInfo();
    }

    //添加XML元素
    private void button2_Click(object sender, EventArgs e)
    {
        XElement xe = XElement.Load(strPath);
        IEnumerable<XElement> elements1 = from element in xe.Elements("People")
                                          select element;
        //生成新的编号
        string str = (Convert.ToInt32(elements1.Max(element => element.Attribute("ID").Value)) + 1).ToString("000");
        XElement people = new XElement(
            "People", new XAttribute("ID", str),
            new XElement("Name", textBox11.Text),
            new XElement("Sex", comboBox1.Text),
            new XElement("Salary", textBox12.Text)
            );
        xe.Add(people);
        xe.Save(strPath);
        getXmlInfo();
    }

    //修改XML元素
    private void button3_Click(object sender, EventArgs e)
    {
        if (strID != "")
        {
            XElement xe = XElement.Load(strPath);
            IEnumerable<XElement> elements = from element in xe.Elements("People")
                                             where element.Attribute("ID").Value == strID
                                             select element;
            if (elements.Count() > 0)
            {
                XElement newXE = elements.First();
                newXE.SetAttributeValue("ID", strID);
                newXE.Replacenodes(
                    new XElement("Name", textBox11.Text),
                    new XElement("Sex", comboBox1.Text),
                    new XElement("Salary", textBox12.Text)
                    );
            }
            xe.Save(strPath);
        } 
        getXmlInfo();
    }

    //删除XML元素
    private void button4_Click(object sender, EventArgs e)
    {
        if (strID != "")
        {
            XElement xe = XElement.Load(strPath);
            IEnumerable<XElement> elements = from element in xe.Elements("People")
                                             where element.Attribute("ID").Value == strID
                                             select element;
            if (elements.Count() > 0)
                elements.First().Remove();
            xe.Save(strPath);
        }
        getXmlInfo();
    }

    //显示选中XML节点的详细信息
    private void dataGridView1_CellClick(object sender, DataGridViewCellEventArgs e)
    {
        strID = dataGridView1.Rows[e.RowIndex].Cells[3].Value.ToString();
        XElement xe = XElement.Load(strPath);
        IEnumerable<XElement> elements = from PInfo in xe.Elements("People")
                                         where PInfo.Attribute("ID").Value == strID
                                         select PInfo;
        foreach (XElement element in elements)
        {
            textBox11.Text = element.Element("Name").Value;
            comboBox1.SelectedItem = element.Element("Sex").Value;
            textBox12.Text = element.Element("Salary").Value;
        }
    }

    #region 将XML文件内容绑定到DataGridView控件
    /// <summary>
    /// 将XML文件内容绑定到DataGridView控件
    /// </summary>
    private void getXmlInfo()
    {
        DataSet myds = new DataSet();
        myds.ReadXml(strPath);
        dataGridView1.DataSource = myds.Tables[0];
    }
    #endregion
}
partial class Form1
{
    /// <summary>
    /// 必需的设计器变量。
    /// </summary>
    private System.ComponentModel.IContainer components = null;

    /// <summary>
    /// 清理所有正在使用的资源。
    /// </summary>
    /// <param name="disposing">如果应释放托管资源,为 true;否则为 false。</param>
    protected override void Dispose(bool disposing)
    {
        if (disposing && (components != null))
        {
            components.Dispose();
        }
        base.Dispose(disposing);
    }

    #region windows 窗体设计器生成的代码

    /// <summary>
    /// 设计器支持所需的方法 - 不要
    /// 使用代码编辑器修改此方法的内容。
    /// </summary>
    private void InitializeComponent()
    {
        this.groupBox1 = new System.Windows.Forms.GroupBox();
        this.textBox10 = new System.Windows.Forms.TextBox();
        this.label10 = new System.Windows.Forms.Label();
        this.button1 = new System.Windows.Forms.Button();
        this.textBox9 = new System.Windows.Forms.TextBox();
        this.label8 = new System.Windows.Forms.Label();
        this.textBox8 = new System.Windows.Forms.TextBox();
        this.label9 = new System.Windows.Forms.Label();
        this.textBox7 = new System.Windows.Forms.TextBox();
        this.label2 = new System.Windows.Forms.Label();
        this.textBox6 = new System.Windows.Forms.TextBox();
        this.label7 = new System.Windows.Forms.Label();
        this.textBox5 = new System.Windows.Forms.TextBox();
        this.label5 = new System.Windows.Forms.Label();
        this.textBox4 = new System.Windows.Forms.TextBox();
        this.label6 = new System.Windows.Forms.Label();
        this.textBox3 = new System.Windows.Forms.TextBox();
        this.label3 = new System.Windows.Forms.Label();
        this.textBox2 = new System.Windows.Forms.TextBox();
        this.label4 = new System.Windows.Forms.Label();
        this.textBox1 = new System.Windows.Forms.TextBox();
        this.label1 = new System.Windows.Forms.Label();
        this.groupBox2 = new System.Windows.Forms.GroupBox();
        this.button4 = new System.Windows.Forms.Button();
        this.button3 = new System.Windows.Forms.Button();
        this.button2 = new System.Windows.Forms.Button();
        this.comboBox1 = new System.Windows.Forms.ComboBox();
        this.textBox12 = new System.Windows.Forms.TextBox();
        this.label12 = new System.Windows.Forms.Label();
        this.label13 = new System.Windows.Forms.Label();
        this.textBox11 = new System.Windows.Forms.TextBox();
        this.label14 = new System.Windows.Forms.Label();
        this.dataGridView1 = new System.Windows.Forms.DataGridView();
        this.groupBox1.SuspendLayout();
        this.groupBox2.SuspendLayout();
        ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).BeginInit();
        this.SuspendLayout();
        // 
        // groupBox1
        // 
        this.groupBox1.Controls.Add(this.textBox10);
        this.groupBox1.Controls.Add(this.label10);
        this.groupBox1.Controls.Add(this.button1);
        this.groupBox1.Controls.Add(this.textBox9);
        this.groupBox1.Controls.Add(this.label8);
        this.groupBox1.Controls.Add(this.textBox8);
        this.groupBox1.Controls.Add(this.label9);
        this.groupBox1.Controls.Add(this.textBox7);
        this.groupBox1.Controls.Add(this.label2);
        this.groupBox1.Controls.Add(this.textBox6);
        this.groupBox1.Controls.Add(this.label7);
        this.groupBox1.Controls.Add(this.textBox5);
        this.groupBox1.Controls.Add(this.label5);
        this.groupBox1.Controls.Add(this.textBox4);
        this.groupBox1.Controls.Add(this.label6);
        this.groupBox1.Controls.Add(this.textBox3);
        this.groupBox1.Controls.Add(this.label3);
        this.groupBox1.Controls.Add(this.textBox2);
        this.groupBox1.Controls.Add(this.label4);
        this.groupBox1.Controls.Add(this.textBox1);
        this.groupBox1.Controls.Add(this.label1);
        this.groupBox1.Location = new System.Drawing.Point(6, 3);
        this.groupBox1.Name = "groupBox1";
        this.groupBox1.Size = new System.Drawing.Size(451, 190);
        this.groupBox1.TabIndex = 18;
        this.groupBox1.TabStop = false;
        this.groupBox1.Text = "创建XML文件";
        // 
        // textBox10
        // 
        this.textBox10.Location = new System.Drawing.Point(319, 47);
        this.textBox10.Name = "textBox10";
        this.textBox10.ReadOnly = true;
        this.textBox10.Size = new System.Drawing.Size(119, 21);
        this.textBox10.TabIndex = 3;
        this.textBox10.Text = "001";
        // 
        // label10
        // 
        this.label10.AutoSize = true;
        this.label10.Location = new System.Drawing.Point(236, 50);
        this.label10.Name = "label10";
        this.label10.Size = new System.Drawing.Size(89, 12);
        this.label10.TabIndex = 21;
        this.label10.Text = "子节点属性值:";
        // 
        // button1
        // 
        this.button1.Location = new System.Drawing.Point(363, 158);
        this.button1.Name = "button1";
        this.button1.Size = new System.Drawing.Size(75, 23);
        this.button1.TabIndex = 10;
        this.button1.Text = "创建";
        this.button1.UseVisualStyleBackColor = true;
        this.button1.Click += new System.EventHandler(this.button1_Click);
        // 
        // textBox9
        // 
        this.textBox9.Location = new System.Drawing.Point(319, 131);
        this.textBox9.Name = "textBox9";
        this.textBox9.Size = new System.Drawing.Size(119, 21);
        this.textBox9.TabIndex = 9;
        // 
        // label8
        // 
        this.label8.AutoSize = true;
        this.label8.Location = new System.Drawing.Point(236, 134);
        this.label8.Name = "label8";
        this.label8.Size = new System.Drawing.Size(89, 12);
        this.label8.TabIndex = 18;
        this.label8.Text = "第三个元素值:";
        // 
        // textBox8
        // 
        this.textBox8.Location = new System.Drawing.Point(111, 131);
        this.textBox8.Name = "textBox8";
        this.textBox8.ReadOnly = true;
        this.textBox8.Size = new System.Drawing.Size(119, 21);
        this.textBox8.TabIndex = 8;
        this.textBox8.Text = "Salary";
        // 
        // label9
        // 
        this.label9.AutoSize = true;
        this.label9.Location = new System.Drawing.Point(12, 134);
        this.label9.Name = "label9";
        this.label9.Size = new System.Drawing.Size(101, 12);
        this.label9.TabIndex = 16;
        this.label9.Text = "第三个元素名称:";
        // 
        // textBox7
        // 
        this.textBox7.Location = new System.Drawing.Point(319, 103);
        this.textBox7.Name = "textBox7";
        this.textBox7.Size = new System.Drawing.Size(119, 21);
        this.textBox7.TabIndex = 7;
        // 
        // label2
        // 
        this.label2.AutoSize = true;
        this.label2.Location = new System.Drawing.Point(236, 106);
        this.label2.Name = "label2";
        this.label2.Size = new System.Drawing.Size(89, 12);
        this.label2.TabIndex = 14;
        this.label2.Text = "第二个元素值:";
        // 
        // textBox6
        // 
        this.textBox6.Location = new System.Drawing.Point(111, 103);
        this.textBox6.Name = "textBox6";
        this.textBox6.ReadOnly = true;
        this.textBox6.Size = new System.Drawing.Size(119, 21);
        this.textBox6.TabIndex = 6;
        this.textBox6.Text = "Sex";
        // 
        // label7
        // 
        this.label7.AutoSize = true;
        this.label7.Location = new System.Drawing.Point(12, 106);
        this.label7.Name = "label7";
        this.label7.Size = new System.Drawing.Size(101, 12);
        this.label7.TabIndex = 12;
        this.label7.Text = "第二个元素名称:";
        // 
        // textBox5
        // 
        this.textBox5.Location = new System.Drawing.Point(319, 75);
        this.textBox5.Name = "textBox5";
        this.textBox5.Size = new System.Drawing.Size(119, 21);
        this.textBox5.TabIndex = 5;
        // 
        // label5
        // 
        this.label5.AutoSize = true;
        this.label5.Location = new System.Drawing.Point(236, 78);
        this.label5.Name = "label5";
        this.label5.Size = new System.Drawing.Size(89, 12);
        this.label5.TabIndex = 10;
        this.label5.Text = "第一个元素值:";
        // 
        // textBox4
        // 
        this.textBox4.Location = new System.Drawing.Point(111, 75);
        this.textBox4.Name = "textBox4";
        this.textBox4.ReadOnly = true;
        this.textBox4.Size = new System.Drawing.Size(119, 21);
        this.textBox4.TabIndex = 4;
        this.textBox4.Text = "Name";
        // 
        // label6
        // 
        this.label6.AutoSize = true;
        this.label6.Location = new System.Drawing.Point(12, 78);
        this.label6.Name = "label6";
        this.label6.Size = new System.Drawing.Size(101, 12);
        this.label6.TabIndex = 8;
        this.label6.Text = "第一个元素名称:";
        // 
        // textBox3
        // 
        this.textBox3.Location = new System.Drawing.Point(111, 47);
        this.textBox3.Name = "textBox3";
        this.textBox3.ReadOnly = true;
        this.textBox3.Size = new System.Drawing.Size(119, 21);
        this.textBox3.TabIndex = 2;
        this.textBox3.Text = "ID";
        // 
        // label3
        // 
        this.label3.AutoSize = true;
        this.label3.Location = new System.Drawing.Point(28, 50);
        this.label3.Name = "label3";
        this.label3.Size = new System.Drawing.Size(77, 12);
        this.label3.TabIndex = 6;
        this.label3.Text = "子节点属性:";
        // 
        // textBox2
        // 
        this.textBox2.Location = new System.Drawing.Point(319, 20);
        this.textBox2.Name = "textBox2";
        this.textBox2.ReadOnly = true;
        this.textBox2.Size = new System.Drawing.Size(119, 21);
        this.textBox2.TabIndex = 1;
        this.textBox2.Text = "People";
        // 
        // label4
        // 
        this.label4.AutoSize = true;
        this.label4.Location = new System.Drawing.Point(248, 23);
        this.label4.Name = "label4";
        this.label4.Size = new System.Drawing.Size(77, 12);
        this.label4.TabIndex = 4;
        this.label4.Text = "子节点名称:";
        // 
        // textBox1
        // 
        this.textBox1.Location = new System.Drawing.Point(111, 20);
        this.textBox1.Name = "textBox1";
        this.textBox1.ReadOnly = true;
        this.textBox1.Size = new System.Drawing.Size(119, 21);
        this.textBox1.TabIndex = 0;
        this.textBox1.Text = "Peoples";
        // 
        // label1
        // 
        this.label1.AutoSize = true;
        this.label1.Location = new System.Drawing.Point(19, 23);
        this.label1.Name = "label1";
        this.label1.Size = new System.Drawing.Size(89, 12);
        this.label1.TabIndex = 0;
        this.label1.Text = "顶级节点名称:";
        // 
        // groupBox2
        // 
        this.groupBox2.Controls.Add(this.button4);
        this.groupBox2.Controls.Add(this.button3);
        this.groupBox2.Controls.Add(this.button2);
        this.groupBox2.Controls.Add(this.comboBox1);
        this.groupBox2.Controls.Add(this.textBox12);
        this.groupBox2.Controls.Add(this.label12);
        this.groupBox2.Controls.Add(this.label13);
        this.groupBox2.Controls.Add(this.textBox11);
        this.groupBox2.Controls.Add(this.label14);
        this.groupBox2.Location = new System.Drawing.Point(6, 198);
        this.groupBox2.Name = "groupBox2";
        this.groupBox2.Size = new System.Drawing.Size(451, 80);
        this.groupBox2.TabIndex = 19;
        this.groupBox2.TabStop = false;
        this.groupBox2.Text = "操作XML文件";
        // 
        // button4
        // 
        this.button4.Location = new System.Drawing.Point(360, 47);
        this.button4.Name = "button4";
        this.button4.Size = new System.Drawing.Size(63, 23);
        this.button4.TabIndex = 16;
        this.button4.Text = "删除";
        this.button4.UseVisualStyleBackColor = true;
        this.button4.Click += new System.EventHandler(this.button4_Click);
        // 
        // button3
        // 
        this.button3.Location = new System.Drawing.Point(291, 47);
        this.button3.Name = "button3";
        this.button3.Size = new System.Drawing.Size(63, 23);
        this.button3.TabIndex = 15;
        this.button3.Text = "修改";
        this.button3.UseVisualStyleBackColor = true;
        this.button3.Click += new System.EventHandler(this.button3_Click);
        // 
        // button2
        // 
        this.button2.Location = new System.Drawing.Point(222, 47);
        this.button2.Name = "button2";
        this.button2.Size = new System.Drawing.Size(63, 23);
        this.button2.TabIndex = 14;
        this.button2.Text = "添加";
        this.button2.UseVisualStyleBackColor = true;
        this.button2.Click += new System.EventHandler(this.button2_Click);
        // 
        // comboBox1
        // 
        this.comboBox1.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
        this.comboBox1.FormattingEnabled = true;
        this.comboBox1.Items.AddRange(new object[] {
        "男",
        "女"});
        this.comboBox1.Location = new System.Drawing.Point(286, 20);
        this.comboBox1.Name = "comboBox1";
        this.comboBox1.Size = new System.Drawing.Size(121, 20);
        this.comboBox1.TabIndex = 12;
        // 
        // textBox12
        // 
        this.textBox12.Location = new System.Drawing.Point(85, 49);
        this.textBox12.Name = "textBox12";
        this.textBox12.Size = new System.Drawing.Size(119, 21);
        this.textBox12.TabIndex = 13;
        // 
        // label12
        // 
        this.label12.AutoSize = true;
        this.label12.Location = new System.Drawing.Point(19, 52);
        this.label12.Name = "label12";
        this.label12.Size = new System.Drawing.Size(65, 12);
        this.label12.TabIndex = 27;
        this.label12.Text = "职工薪水:";
        // 
        // label13
        // 
        this.label13.AutoSize = true;
        this.label13.Location = new System.Drawing.Point(220, 23);
        this.label13.Name = "label13";
        this.label13.Size = new System.Drawing.Size(65, 12);
        this.label13.TabIndex = 25;
        this.label13.Text = "职工性别:";
        // 
        // textBox11
        // 
        this.textBox11.Location = new System.Drawing.Point(85, 20);
        this.textBox11.Name = "textBox11";
        this.textBox11.Size = new System.Drawing.Size(119, 21);
        this.textBox11.TabIndex = 11;
        // 
        // label14
        // 
        this.label14.AutoSize = true;
        this.label14.Location = new System.Drawing.Point(19, 23);
        this.label14.Name = "label14";
        this.label14.Size = new System.Drawing.Size(65, 12);
        this.label14.TabIndex = 23;
        this.label14.Text = "职工姓名:";
        // 
        // dataGridView1
        // 
        this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
        this.dataGridView1.Location = new System.Drawing.Point(6, 284);
        this.dataGridView1.Name = "dataGridView1";
        this.dataGridView1.RowTemplate.Height = 23;
        this.dataGridView1.Size = new System.Drawing.Size(451, 171);
        this.dataGridView1.TabIndex = 17;
        this.dataGridView1.CellClick += new System.Windows.Forms.DataGridViewCellEventHandler(this.dataGridView1_CellClick);
        // 
        // Form1
        // 
        this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 12F);
        this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
        this.ClientSize = new System.Drawing.Size(462, 460);
        this.Controls.Add(this.dataGridView1);
        this.Controls.Add(this.groupBox2);
        this.Controls.Add(this.groupBox1);
        this.Name = "Form1";
        this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
        this.Text = "使用Linq To XML操作XML文件";
        this.Load += new System.EventHandler(this.Form1_Load);
        this.groupBox1.ResumeLayout(false);
        this.groupBox1.PerformLayout();
        this.groupBox2.ResumeLayout(false);
        this.groupBox2.PerformLayout();
        ((System.ComponentModel.ISupportInitialize)(this.dataGridView1)).EndInit();
        this.ResumeLayout(false);

    }

    #endregion

    private System.Windows.Forms.GroupBox groupBox1;
    private System.Windows.Forms.Label label1;
    private System.Windows.Forms.TextBox textBox5;
    private System.Windows.Forms.Label label5;
    private System.Windows.Forms.TextBox textBox4;
    private System.Windows.Forms.Label label6;
    private System.Windows.Forms.TextBox textBox3;
    private System.Windows.Forms.Label label3;
    private System.Windows.Forms.TextBox textBox2;
    private System.Windows.Forms.Label label4;
    private System.Windows.Forms.TextBox textBox1;
    private System.Windows.Forms.TextBox textBox7;
    private System.Windows.Forms.Label label2;
    private System.Windows.Forms.TextBox textBox6;
    private System.Windows.Forms.Label label7;
    private System.Windows.Forms.TextBox textBox9;
    private System.Windows.Forms.Label label8;
    private System.Windows.Forms.TextBox textBox8;
    private System.Windows.Forms.Label label9;
    private System.Windows.Forms.Button button1;
    private System.Windows.Forms.TextBox textBox10;
    private System.Windows.Forms.Label label10;
    private System.Windows.Forms.GroupBox groupBox2;
    private System.Windows.Forms.DataGridView dataGridView1;
    private System.Windows.Forms.TextBox textBox12;
    private System.Windows.Forms.Label label12;
    private System.Windows.Forms.Label label13;
    private System.Windows.Forms.TextBox textBox11;
    private System.Windows.Forms.Label label14;
    private System.Windows.Forms.ComboBox comboBox1;
    private System.Windows.Forms.Button button4;
    private System.Windows.Forms.Button button3;
    private System.Windows.Forms.Button button2;
}

到此这篇关于C#实现利用Linq操作Xml文件的文章就介绍到这了,更多相关C# Linq操作Xml内容请搜索编程网以前的文章或继续浏览下面的相关文章希望大家以后多多支持编程网!

--结束END--

本文标题: C#实现利用Linq操作Xml文件

本文链接: https://www.lsjlt.com/news/176158.html(转载时请注明来源链接)

有问题或投稿请发送至: 邮箱/279061341@qq.com    QQ/279061341

本篇文章演示代码以及资料文档资料下载

下载Word文档到电脑,方便收藏和打印~

下载Word文档
猜你喜欢
  • C#实现利用Linq操作Xml文件
    目录实践过程效果代码实践过程 效果 代码 public partial class Form1 : Form { public Form1() { ...
    99+
    2022-12-29
    C# Linq操作Xml C# 操作Xml C# Linq Xml
  • C#实现XML文件操作详解
    目录实践过程效果代码实践过程 效果 代码 public partial class Form1 : Form { public Form1() { ...
    99+
    2022-12-23
    C# XML文件操作 C# XML 操作 C# XML
  • C#实用教程操作xml文件
    操作XML文件是C#编程中非常常见的任务之一。下面是一个简单的C#实用教程,演示如何使用C#读取、编辑和保存XML文件。读取XML文...
    99+
    2023-09-15
    C#
  • 利用dom4j如何实现操作xml文件中的demo
    本篇文章为大家展示了利用dom4j如何实现操作xml文件中的demo,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。废话不多说,直接上代码package com.cn.shop.util;import...
    99+
    2023-05-31
    dom4j xml demo
  • java 中怎么利用org.w3c.dom操作XML文件
    java 中怎么利用org.w3c.dom操作XML文件,针对这个问题,这篇文章详细介绍了相对应的分析和解答,希望可以帮助更多想解决这个问题的小伙伴找到更简单易行的方法。下面直接贴出样例代码:import javax.xml.pa...
    99+
    2023-06-20
  • C#操作xml文件的方法
    本篇内容介绍了“C#操作xml文件的方法”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!C#操作xml文件实例是如何的呢?让我们先看看问题:已...
    99+
    2023-06-17
  • python操作Xml文件
    一、简单介绍Xml是实现不同语言或程序进行数据交换的协议,跟json差不多,但是xml远远先于json出现,例如在很多传统的金融行业的很多系统接口还主要是xml格式。Xml的格式如下:<Settings modified="2016-...
    99+
    2023-01-31
    操作 文件 python
  • C#操作XML文件要注意什么
    本篇内容主要讲解“C#操作XML文件要注意什么”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“C#操作XML文件要注意什么”吧!要对XML文件进行操作,须要声明以下命名空间:using Syste...
    99+
    2023-06-17
  • Python对XML文件实现增删改查操作
    目录PYTHON 操作 XML读取XML文件遍历XML元素查找XML元素添加XML元素修改XML元素PYTHON 操作 XML 读取XML文件 关于XML的介绍 <data&g...
    99+
    2022-11-13
    Python XML增删改查 Python XML操作 Python XML修改
  • 利用HDFS怎么实现多文件Join操作
    本篇文章为大家展示了利用HDFS怎么实现多文件Join操作,内容简明扼要并且容易理解,绝对能使你眼前一亮,通过这篇文章的详细介绍希望你能有所收获。详解HDFS多文件Join操作的实例最近在做HDFS文件处理之时,遇到了多文件Join操作,其...
    99+
    2023-05-31
    hdfs join
  • Qt利用DOM类实现读取xml文件
    目录一、项目介绍二、项目基本配置三、UI界面设计四、主程序实现4.1 node.xml4.2 pro文件4.3 main.cpp五、效果演示一、项目介绍 利用DOM相关类读取xml文...
    99+
    2024-04-02
  • Python如何操作XML文件
    这篇文章主要介绍“Python如何操作XML文件”,在日常操作中,相信很多人在Python如何操作XML文件问题上存在疑惑,小编查阅了各式资料,整理出简单好用的操作方法,希望对大家解答”Python如何操作XML文件”的疑惑有所帮助!接下来...
    99+
    2023-06-30
  • C#实现文件Move和Copy操作
    文件移动(Move)操作和文件的复制(Copy)是C#程式开发经常遇到的方法,根据传入的源文件地址和目标文件地址参数,实现对文件的操作。实现代码如下: Move操作代码 public...
    99+
    2024-04-02
  • C#操作文本文件的实现方式
    本篇内容主要讲解“C#操作文本文件的实现方式”,感兴趣的朋友不妨来看看。本文介绍的方法操作简单快捷,实用性强。下面就让小编来带大家学习“C#操作文本文件的实现方式”吧!C#操作文本文件是如何实现的呢?让我们开始讲述吧:using ...
    99+
    2023-06-17
  • R语言操作XML文件实例分析
    XML是一种文件格式,它使用标准ASCII文本共享万维网,内部网和其他地方的文件格式和数据。 它代表可扩展标记语言(XML)。 类似于HTML它包含标记标签。 但是与HTML中的标记...
    99+
    2024-04-02
  • Python操作XML文件的使用指南
    目录什么是 XMLPython XML 解析模块xml.etree.ElementTree 模块使用 parse() 函数使用 fromstring() 函数寻找感兴趣的元素修改 X...
    99+
    2024-04-02
  • java 如何使用org.w3c.dom操作XML文件
    本篇介绍在java中,如何使用org.w3c.dom中的相关内容来操作XML文件。包括: 如何在内存中构建XML文件并写入磁盘; 如何从磁盘读取XML文件到内存; ...
    99+
    2024-04-02
  • C#如何利用File方法对文件操作
    这篇文章给大家分享的是有关C#如何利用File方法对文件操作的内容。小编觉得挺实用的,因此分享给大家做个参考,一起跟随小编过来看看吧。C#文件的读和写提供了非常多的方法基本一两行就可以搞定“读和写”,在编程里还是比较重要的什么是读?你的程序...
    99+
    2023-06-20
  • 三十二、python操作XML文件
    ''' XML:模块 xml总结 1、解析 str 文件 tree,ElementTree,type root,Element,type 2、操作 Element: tag,text,fin...
    99+
    2023-01-31
    操作 文件 三十二
  • C++中怎么实现文件流操作
    本篇文章给大家分享的是有关C++中怎么实现文件流操作,小编觉得挺实用的,因此分享给大家学习,希望大家阅读完这篇文章后可以有所收获,话不多说,跟着小编一起来看看吧。C++文件流操作之文件写入:#include < f...
    99+
    2023-06-17
软考高级职称资格查询
编程网,编程工程师的家园,是目前国内优秀的开源技术社区之一,形成了由开源软件库、代码分享、资讯、协作翻译、讨论区和博客等几大频道内容,为IT开发者提供了一个发现、使用、并交流开源技术的平台。
  • 官方手机版

  • 微信公众号

  • 商务合作