默认情况下,读取xml文件是不忽略注释的,这样读取带注释的节点会造成异常,那么怎么屏蔽掉这些注释呢?
方案如下:
XmlDocument doc = new XmlDocument(); XmlReaderSettings settings = new XmlReaderSettings(); settings.IgnoreComments = true; //xmlFilePath:xml文件路径 XmlReader reader = XmlReader.Create(xmlFilePath, settings); doc.Load(reader);
原文地址:http://blog.csdn.net/jiankunking/article/details/42300681