zoukankan      html  css  js  c++  java
  • Linq to xml:XElement拼装

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using System.Xml.Linq;

    namespace linq
    {
        class Program
        {
            static void Main(string[] args)
            {
                XElement x = new XElement("body",
                    new XElement("form",
                        new XElement("ID", 99999),
                        new XElement("name", "zhangsan")
                        )
                        );
                XElement y = new XElement("body",
                    new XElement("form",
                        new XElement("ID", 88888),
                        new XElement("name", "lisa")
                        )
                        );

                //组装
                XElement z = new XElement("ROOT",
                                new XElement("bodys",
                                    x,y
                                    )
                                    );

                XElement srcTree = new XElement("Root",
                    new XElement("Element", 1),
                    new XElement("Element", 2),
                    new XElement("Element", 3),
                    new XElement("Element", 4),
                    new XElement("Element", 5)
                );
                XElement xmlTree = new XElement("Root",
                    new XElement("Child", 1),
                    new XElement("Child", 2),
                    from el in srcTree.Elements()
                    where (int)el > 2
                    select el
                );


                Console.WriteLine(z);
                Console.ReadLine();
            }
        }
    }

    关于作者: 王昕(QQ:475660) 在广州工作生活30余年。十多年开发经验,在Java、即时通讯、NoSQL、BPM、大数据等领域较有经验。
    目前维护的开源产品:https://gitee.com/475660
  • 相关阅读:
    全局变量引用与声明
    Oracle基础~dg原理
    Oracle基础~dg管理
    Oracle基础~rman克隆
    oracle基础~rman恢复篇
    oracle基础~linux整体性能优化
    oracle基础~报错汇总与解决办法
    oracle基础~用户和权限
    oracle基础~rac-asm
    oracle基础~awr报告
  • 原文地址:https://www.cnblogs.com/starcrm/p/1362733.html
Copyright © 2011-2022 走看看