diff --git a/Client/Assets/Scripts/Data/DefinePack.cs b/Client/Assets/Scripts/Data/DefinePack.cs index 3e03d1f..e14972d 100644 --- a/Client/Assets/Scripts/Data/DefinePack.cs +++ b/Client/Assets/Scripts/Data/DefinePack.cs @@ -1,4 +1,6 @@ +using System; using System.Collections.Generic; +using System.Xml; namespace Data { @@ -16,7 +18,39 @@ namespace Data 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; + } } } \ No newline at end of file