当前位置:网站首页>C operation XML file
C operation XML file
2022-07-05 11:27:00 【Full stack programmer webmaster】
using System; using System.Collections.Generic; using System.Data; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Xml;
namespace delegatedemo { public class XmlClass { private string xmlPath; public XmlClass(string xmlPath) { this.xmlPath = xmlPath; }
public DataView GetXmlElement() { DataTable myTable = new DataTable(); DataRow myRow; myTable.Columns.Add(“ Student number ”); myTable.Columns.Add(“ full name ”); myTable.Columns.Add(“ Age ”); myTable.Columns.Add(“ Gender ”); XmlDocument doc = new XmlDocument(); doc.Load(xmlPath); XmlElement xmlElement = doc.DocumentElement; foreach (XmlNode node in xmlElement.ChildNodes) { string number = node.Attributes[“number”].Value; string age = node.SelectSingleNode(“Age”).InnerText; string name = node.SelectSingleNode(“Name”).InnerText; string sex = node.SelectSingleNode(“Sex”).InnerText; myRow = myTable.NewRow(); myRow[“ Student number ”] = number; myRow[“ full name ”] = name; myRow[“ Gender ”] = sex; myRow[“ Age ”] = age; myTable.Rows.Add(myRow); } return myTable.DefaultView; }
public void InsertXml() { XmlDocument doc = new XmlDocument(); doc.Load(xmlPath); XmlElement root = doc.DocumentElement; XmlElement student = doc.CreateElement(“student”); student.SetAttribute(“number”, “003”); XmlElement name = doc.CreateElement(“name”); name.InnerText = “ Zhang San ”; XmlElement age = doc.CreateElement(“age”); age.InnerText = “21”; XmlElement sex = doc.CreateElement(“sex”); sex.InnerText = “ Woman ”; root.AppendChild(student); root.AppendChild(name); root.AppendChild(age); root.AppendChild(sex); doc.Save(xmlPath); } } }
Publisher : Full stack programmer stack length , Reprint please indicate the source :https://javaforall.cn/109546.html Link to the original text :https://javaforall.cn
边栏推荐
猜你喜欢
![[advertising system] parameter server distributed training](/img/8b/558c2fefbd16b580546003f3afeaf5.png)
[advertising system] parameter server distributed training

Codeforces Round #804 (Div. 2)

如何让全彩LED显示屏更加节能环保

In the last process before the use of the risk control model, 80% of children's shoes are trampled here

Evolution of multi-objective sorting model for classified tab commodity flow

Detailed explanation of MATLAB cov function

Ddrx addressing principle

Summary of thread and thread synchronization under window

DDRx寻址原理

Three suggestions for purchasing small spacing LED display
随机推荐
2048游戏逻辑
数据库三大范式
[advertising system] parameter server distributed training
【广告系统】增量训练 & 特征准入/特征淘汰
爬虫(9) - Scrapy框架(1) | Scrapy 异步网络爬虫框架
spark调优(一):从hql转向代码
Wechat nucleic acid detection appointment applet system graduation design completion (6) opening defense ppt
Beego cross domain problem solution - successful trial
Ffmpeg calls avformat_ open_ Error -22 returned during input (invalid argument)
Dspic33ep clock initialization program
Advanced technology management - what is the physical, mental and mental strength of managers
Three paradigms of database
Manage multiple instagram accounts and share anti Association tips
Zcmu--1390: queue problem (1)
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
How did the situation that NFT trading market mainly uses eth standard for trading come into being?
ZCMU--1390: 队列问题(1)
Intelligent metal detector based on openharmony
msfconsole命令大全,以及使用说明
Cdga | six principles that data governance has to adhere to