using System; using System.Collections.Generic; using System.Xml; namespace Data { public struct PackAbout { public string name; public string description; public string author; } public class DefinePack { public string packID; public PackAbout packAbout; public List defines; public void LoadPack(string packPath) { var packDatas=Utils.FileHandler.LoadXmlFromPath(packPath); } /// /// 从 ListXmlDocument 中查找指定根元素名称的文档。 /// /// XML 文档列表。 /// 目标根元素名称。 /// 符合条件的 XML 文档列表。 public static List FindDocumentsWithRootName(List xmlDocuments, string rootName) { var result = new List(); foreach (var xmlDoc in xmlDocuments) { try { // 获取根节点 var root = xmlDoc.DocumentElement; if (root != null && root.Name == rootName) { // 如果根节点名称匹配,则添加到结果列表 result.Add(xmlDoc); } } catch (Exception ex) { Console.Error.WriteLine($"处理 XML 文档时发生错误: {ex.Message}"); } } return result; } } }