C#读写xml文件


using System.Xml.Linq;
protected void WriteXml(string path)
{
    XDocument Xdoc = new XDocument(
    new XDeclaration("1.0","utf-8","yes"),
    new XComment("Create Time:"+DateTime.Now),
    new XElement("mybook",
        new XElement("bookfir",
        new XAttribute("id",1),
        new XAttribute("name","book1"),
        new XElement("bookname","asp.net"),
        new XElement("bookprice",100)
        ),
        new XElement("booksec",
        new XAttribute("id",2),
        new XAttribute("name","book2"),
        new XElement("bookname","php"),
        new XElement("price",200)
        )
        )
    );
    Xdoc.Save(path);
}

优质内容筛选与推荐>>
1、IOS 旋转+缩放(手势识别)
2、HTML知识点
3、DundasWebChart5.5.1.1711图表组件(转)
4、[转]Android Art Hook 技术方案
5、modbus协议之串行链路


长按二维码向我转账

受苹果公司新规定影响,微信 iOS 版的赞赏功能被关闭,可通过二维码转账支持公众号。

    阅读
    好看
    已推荐到看一看
    你的朋友可以在“发现”-“看一看”看到你认为好看的文章。
    已取消,“好看”想法已同步删除
    已推荐到看一看 和朋友分享想法
    最多200字,当前共 发送

    已发送

    朋友将在看一看看到

    确定
    分享你的想法...
    取消

    分享想法到看一看

    确定
    最多200字,当前共

    发送中

    网络异常,请稍后重试

    微信扫一扫
    关注该公众号