步骤
1.使用Altova XMLSpy按照需求设计生成xsd文件
2.使用xsd验证xml文件
3.使用批处理生成c#类文件
参数如下:
SET OUTPUT=D:\digitnexus-
project\trunk\com.dn.Edgenode\com.dn.Edgenode.Core\Configuration
SET DIR=D:\digitnexus-project\trunk\com.dn.Edgenode\com.dn.Edgenode.Core\Configuration
SET FILE=EdgenodeConfig.xsd XSD /l:C# /c /nologo /n:com.dn.Edgenode.Core.Configuration %DIR%\%FILE% /o:%OUTPUT%
第一个为类输出地址
第二个xsd文件地址
第三个xsd文件名字
最后一行红色包含类的命名空间
4.调用类文件:
private edgenodeType _edgenodeCfg;
string cfgPath = Path.Combine(Root, System.Configuration.ConfigurationManager.AppSettings["EdgenodeConfigFile"]);
if (_edgenodeCfg == null)
{
if (File.Exists(cfgPath))
{
XmlDocument xml = new XmlDocument();
xml.Load(cfgPath);
string xmltxt = xml.OuterXml;
_edgenodeCfg = edgenodeType.Parse(xmltxt);
}
}
<script type="text/javascript"> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>