读取xml到DataSet中去

本文介绍了一个税务系统的配置文件结构及读取方式,包括单点登录、凭证服务等组件的详细配置,并展示了如何通过C#代码读取这些配置。

XML如下:

<?xml version="1.0" encoding="utf-8" ?>
<Config>
  <System>
    <BaseServer Name="SSO"  Title="单点登录" Server="http://10.254.2.22:9010/"></BaseServer>
    <BaseServer Name="TICKET"  Title="凭证服务" Server="http://10.254.2.22:9980/"></BaseServer>
  </System>
  <Components>
    <Component Name="mxsbcztdsys" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.Mxsb.Cztdsys.dll"  Interface="Hlwdsj.Mxsb.Cztdsys.CztdsysFunction" TileConfigFile="" Title="明细申报-城镇土地使用税" Server="http://10.254.2.169:8080/"/>
    <Component Name="mxsbZys" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.Mxsb.ZYS.dll" Interface="Hlwdsj.Mxsb.ZYS.ZYSFunction" TileConfigFile="" Title="明细申报-资源税" Server="http://10.254.2.42:9000/"/>
    <Component Name="qysdsjb" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.QysdsJb.dll" Interface="Hlwdsj.QysdsJb.QysdsJbFunction" TileConfigFile="" Title="企业所得税申报系统" Server="http://10.254.2.86:8080/"/>
    <Component Name="mxsbGrsds" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.GrsdsMxsb.dll"  Interface="Hlwdsj.GrsdsMxsb.GsMxsbFunction" TileConfigFile="" Title="个税明细申报" Server="http://10.254.2.52:9900/"/>
    <Component Name="mxsbZskp" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.Mxsb.Zskp.dll"  Interface="Hlwdsj.Mxsb.Zskp.ZskpFunction" TileConfigFile="" Title="征收开票" Server="http://10.254.2.180:8888/"/>
    <Component Name="wtgsdzfjs" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.Gt3Wtgsdzfjs.dll"  Interface="Hlwdsj.Gt3Wtgsdzfjs.WtgsdzfjsFunction" TileConfigFile="" Title="委托国税代征附加税" Server="http://10.254.2.180:8888/"/>
    <Component Name="kjqysdsbadj" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.Gt3Kjqysdsbadj.dll"  Interface="Hlwdsj.Gt3Kjqysdsbadj.KjqysdsbadjFunction" TileConfigFile="" Title="报备扣缴企业所得税合同备案登记表" Server="http://10.254.2.180:8888/"/>
    <Component Name="mxsbYhs" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.Mxsb.Yhs.dll"  Interface="Hlwdsj.Mxsb.Yhs.YhsFunction" TileConfigFile="" Title="明细申报-印花税" Server="http://10.254.2.243:8081/"/>
    <!--<Component Name="mxsbSzdj" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.Mxsb.Szdj.dll"  Interface="Hlwdsj.Mxsb.Szdj.SzdjFunction" TileConfigFile="" Title="税(费)种认定" Server="http://10.254.2.180:8888/"/>-->
    <Component Name="mxsbTysb" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.Tysb.dll"  Interface="Hlwdsj.Tysb.TysbFunction" TileConfigFile="" Title="通用申报" Server="http://10.254.2.162:8080/"/>
    <Component Name="ssspbpm" DependComponent="hxzg" IntegrationType="SSO" Assembly="Hlwdsj.Sssp.BPM.dll" Interface="Hlwdsj.Sssp.BPM.BPMFunction" TileConfigFile="" Title="审批事项" Server="http://10.254.2.22:3080/;http://10.254.2.22:9080/;http://10.254.2.22/;10.254.2.230,8888"/>
    <Component Name="gt3sssp" DependComponent="" IntegrationType="DefaultAdd" Assembly="Hlwdsj.Gt3Sssp.dll" Interface="Hlwdsj.Gt3Sssp.SsspGt3Function" TileConfigFile="" Title="审批事项-金三" Server="http://10.254.2.22:3080/"/>
    <Component Name="Zysssp" DependComponent="" IntegrationType="DefaultAdd" Assembly="Hlwdsj.ZySssp.dll" Interface="Hlwdsj.ZySssp.SsspFunction" TileConfigFile="" Title="审批事项事项-自有" Server="http://10.254.2.22:3080/"/>
    <Component Name="WWGL" DependComponent="" IntegrationType="SSO" Assembly="Hlwdsj.Gt3Wwgl.dll"  Interface="Hlwdsj.Gt3Wwgl.WwglFunction" TileConfigFile="" Title="外网管理" Server="http://10.254.2.243:8081/"/>
  </Components>
</Config>
XML

读取XML代码如下:

  
 SystemTileConfigFile = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, @"Config\TileConfig.xml");
if (!File.Exists(SystemComponentConfigFile))
                throw new Exception(string.Format("系统核心配置文件“{0}”丢失", SystemComponentConfigFile));
            try
            {
                DataSet ds = new DataSet();
                ds.ReadXml(SystemComponentConfigFile);
                DataTable dt = ds.Tables["BaseServer"];
                foreach (DataRow dr in dt.Rows)
                {
                    ssoServer.Add(dr["Name"].ToString(), dr["Server"].ToString());
                }
C#

 

转载于:https://www.cnblogs.com/weiweiboqi/p/5663625.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值