分享一个博主自己写的XML文件操作的基本工具类:
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
using System.Xml.Linq;
namespace ClassLibrary1
{
public class xml
{
/// <summary>
/// 生成xml 文件
/// </summary>
/// <param name="xmlpath">路径</param>
public void CreateXml(string xmlpath)
{
//创建XML 格式
XElement xElement = new XElement(
new XElement("BookStore",new XElement("Book",
new XElement("Name", "C#入门",
new XAttribute("BookName", "C#")),
new XElement("Author", "Martin",
new XAttribute("Name", "Martin")),
new XElement("Adress",