通过XmlDocument修改带有DOCTYPE的xml文件遇到如下问题:
1,断网时直接报错:无法解析此远程名称- 'hibernate.sourceforge.net'
2,连网时修改后:在DOCTYPE行后产生多余字符"[]" --- 这是bug吗 ??
C#代码如下:
XmlDocument mydoc = new XmlDocument();
mydoc.Load(@"d:\hibernate.cfg.xml");
//XmlNode node = mydoc.DocumentElement;//移到config节点
//node = node.FirstChild;//移到database子节点
//node = node.FirstChild;//移到server子节点
//node = node.NextSibling;//移到sa子节点
//node = node.NextSibling;//移到passowrd子节点
//node.InnerText = "sfadsfs";//修改内容
mydoc.Save(@"d:\hibernate.cfg.xml");//保存
XML文件:
<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE hibernate-configuration PUBLIC "-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd"[]>
<hibernate-configuration>
<session-factory>
...
</session-factory>
</hibernate-configuration>
HUWWW