zoukankan      html  css  js  c++  java
  • xml

    using System.Xml.Linq;

    protected static string file = System.Web.HttpContext.Current.Server.MapPath("~/test/ruonanxiao.xml");
            public static string GetName()
            {
                string name = string.Empty;
                XElement doc = XElement.Load(file);
                var names = from p in doc.Descendants("name")
                            select p.Value;
                foreach (var n in names)
                {
                    name = n;
                }
                return name;
            }

            public static string GetSex()
            {
                string name = string.Empty;
                XElement doc = XElement.Load(file);
                var names = from p in doc.Descendants("sex")
                            select p.Value;
                foreach (var n in names)
                {
                    name = n;
                }
                return name;
            }

            public static string GetAge()
            {
                string name = string.Empty;
                XElement doc = XElement.Load(file);
                var names = from p in doc.Descendants("age")
                            select p.Value;
                foreach (var n in names)
                {
                    name = n;
                }
                return name;
            }

  • 相关阅读:
    MVC部分视图
    windows服务
    mvc中seeeion和cook的用法
    @Html.Raw()用法和Html.ActionLink的用法总结
    FileStream类的使用(文件流)
    简单工厂和工厂模式对比
    项目案例【Net Core】如何注入多个服务实现类
    快速查找所有存储过程/触发器中是否包含某个字符串
    TortoiseGit安装与配置
    C# 中==与Equals方法比较
  • 原文地址:https://www.cnblogs.com/ruonanxiao/p/2439789.html
Copyright © 2011-2022 走看看