using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Xml;
namespace testxml
{
class Xmlreader
{
string filePath = "";
public Xmlreader(string FilePath)
{
filePath = FilePath;
}
public string Xmlstr(string nodeName, string properties, string properValue) {
if (filePath == "")
return "";
string xmlStr = "";
XmlReaderSettings settings = new XmlReaderSettings();
settings.IgnoreComments = true;
settings.IgnoreWhitespace = true;
using (XmlReader reader = XmlReader.Create(filePath, settings))
{
reader.MoveToContent();

本文介绍了如何使用C#的XmlReader类来读取大型XML文件,通过设置忽略注释和空白,减少内存占用。提供了一个示例类,包括两个方法:一个用于按条件查找节点并返回XML字符串,另一个用于读取指定路径下的所有子节点。这两个方法有效地提高了处理大型XML文件的效率。

5448

被折叠的 条评论
为什么被折叠?



