From dbc236688a82c1453a1f98a94d5443e2e2d3a670 Mon Sep 17 00:00:00 2001 From: m0_75251201 Date: Sat, 12 Jul 2025 12:04:59 +0800 Subject: [PATCH] =?UTF-8?q?(client)=20feat:=E6=B7=BB=E5=8A=A0=E6=9F=A5?= =?UTF-8?q?=E6=89=BE=E6=8C=87=E5=AE=9A=E6=96=87=E6=A1=A3=E7=B1=BB=E5=9E=8B?= =?UTF-8?q?=E5=87=BD=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Client/Assets/Scripts/Data/DefinePack.cs | 34 ++++++++++++++++++++++++ 1 file changed, 34 insertions(+) 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