加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 百科 > 正文

XML相关

发布时间:2020-12-16 00:30:43 所属栏目:百科 来源:网络整理
导读:创建XML以及读取XML using System;using System.Xml.Linq;namespace CsStudy{ class Program { static void Main() { XDocument xd = new XDocument( new XDeclaration("1.0","utf-8","yes"),new XComment("注释来的"),new XProcessingInstruction("xml-styl

创建XML以及读取XML

using System;
using System.Xml.Linq;

namespace CsStudy
{
    class Program
    {
        static void Main()
        {
            XDocument xd = new XDocument(
                new XDeclaration("1.0","utf-8","yes"),new XComment("注释来的"),new XProcessingInstruction("xml-stylesheet",@"href=""stories.css"" type=""text/css"""),new XElement("员工列表",new XAttribute("color","red"),new XAttribute("size","large"),new XElement("员工",new XElement("姓名","张三"),"李四"))));

            e.Save("e.xml");

            XDocument e2 = XDocument.Load("e.xml");

            Console.WriteLine(e2);

            Console.ReadKey();
        }
    }
}

输出:

<!--注释来的--> <?xml-stylesheet href="stories.css" type="text/css"?> <员工列表 color="red" size="large"> <员工> <姓名>张三</姓名> <姓名>李四</姓名> </员工> </员工列表>

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读