跪求如何动态修改hibernate.cfg.xml的文件
最近开始尝试使用NHibernate,需要动态修改hibernate.cfg.xml文件中的Data Source属性
hibernate.cfg.xml文件如下
<hibernate-configuration xmlns="urn:nhibernate-configuration-2.2" > <session-factory name="NHibernate.Test"> <property name="connection.driver_class">NHibernate.Driver.SQLite20Driver, NHibernate</property> <property name="connection.connection_string"> Data Source=D:\Subject.db3;Version=3 </property> <property name="dialect">NHibernate.Dialect.SQLiteDialect</property> <property name="query.substitutions">true=1;false=0</property> <property name="proxyfactory.factory_class">NHibernate.ByteCode.Castle.ProxyFactoryFactory, NHibernate.ByteCode.Castle</property> </session-factory></hibernate-configuration>
string FileName = "hibernate.cfg.xml"; XmlDocument xmldoc = new XmlDocument(); xmldoc.Load(FileName); XmlNodeList nodeList = xmldoc.SelectSingleNode("hibernate-configuration").ChildNodes;