当前位置:网站首页>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
边栏推荐
- 【广告系统】增量训练 & 特征准入/特征淘汰
- [LeetCode] Wildcard Matching 外卡匹配
- 力扣(LeetCode)185. 部门工资前三高的所有员工(2022.07.04)
- Go language learning notes - first acquaintance with go language
- COMSOL -- 3D casual painting -- sweeping
- Beego cross domain problem solution - successful trial
- 7.2每日学习4
- 技术分享 | 常见接口协议解析
- SLAM 01. Modeling of human recognition Environment & path
- Startup process of uboot:
猜你喜欢
pytorch训练进程被中断了
How to introduce devsecops into enterprises?
Three suggestions for purchasing small spacing LED display
分类TAB商品流多目标排序模型的演进
The ninth Operation Committee meeting of dragon lizard community was successfully held
DDR4的特性与电气参数
In the last process before the use of the risk control model, 80% of children's shoes are trampled here
【广告系统】增量训练 & 特征准入/特征淘汰
CDGA|数据治理不得不坚持的六个原则
Modulenotfounderror: no module named 'scratch' ultimate solution
随机推荐
Manage multiple instagram accounts and share anti Association tips
OneForAll安装使用
Startup process of uboot:
技术管理进阶——什么是管理者之体力、脑力、心力
c#操作xml文件
管理多个Instagram帐户防关联小技巧大分享
Question and answer 45: application of performance probe monitoring principle node JS probe
MySQL giant pit: update updates should be judged with caution by affecting the number of rows!!!
Differences between IPv6 and IPv4 three departments including the office of network information technology promote IPv6 scale deployment
修复动漫1K变8K
[there may be no default font]warning: imagettfbbox() [function.imagettfbbox]: invalid font filename
SLAM 01. Modeling of human recognition Environment & path
[advertising system] incremental training & feature access / feature elimination
解决readObjectStart: expect { or n, but found N, error found in #1 byte of ...||..., bigger context ..
【广告系统】Parameter Server分布式训练
Pytorch training process was interrupted
解决访问国外公共静态资源速度慢的问题
Basic part - basic project analysis
【爬虫】charles unknown错误
Ziguang zhanrui's first 5g R17 IOT NTN satellite in the world has been measured on the Internet of things