zoukankan      html  css  js  c++  java
  • LINQ and some difference between XDocument and XElement

    app.config
    Winform code:
                XElement config = XElement.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
                
    foreach (XElement xe in config.Elements())
                    textBox1.Text 
    += (xe.Name.ToString() + Environment.NewLine);

                XDocument xd 
    = XDocument.Load(AppDomain.CurrentDomain.SetupInformation.ConfigurationFile);
                
    foreach (XElement xe in xd.Elements())
                    textBox1.Text 
    += (xe.Name.ToString() + Environment.NewLine);

    Output:
    MyConfig
    configSections
    connectionStrings
    configuration
    some other XLINQ samples
    There, u can c the differences between XElement and XDocument :)
    In the past, I wrote some XML operation tutorials in non-LINQ time: http://hi.baidu.com/feishunji/blog/category/Xml

    Marius Bancila has also contributed some good introduction articles of LINQ:
    Introduction to LINQ, Part 1: LINQ to Objects
    Introduction to LINQ, Part 2: LINQ to XML
    Introduction to LINQ, Part 3: LINQ to SQL
  • 相关阅读:
    vivado 连接不上板子 There is no current hw_target
    excel 方框打钩
    2019新个税如何计算
    printf("loops %u / %u%c[K ", loops + 1, opts->loops, 27); printf("%cM", 27);
    HttpUtil
    Spring注入bean和aop的注意事项
    获取所有bean的名字
    不可见类有抽象父类,spring配置子类bean,注入父类,aop就可以切父类的方法
    实例/静态工厂方法得到bean
    注入抽象类的子类
  • 原文地址:https://www.cnblogs.com/feishunji/p/1538574.html
Copyright © 2011-2022 走看看