<property key="NCE100">
<value lang="de">Es gibt keine verbindung zu renschief : ${reason}</value>
<value lang="en">Unable to connect to side : ${reason}</value>
<value lang="ja">レンデラー側に接続: ${reason} できません</value>
<value lang="ru">Не могу подключиться к серверу рендерера: ${reason}</value>
<value lang="th">ม่สามารถเชื่อมต่อกับโปรแกรม ได้: ${reason}</value>
<value lang="zh">无法连接:${reason}</value>
<value lang="zh-TW">無法連接:${reason}</value>
</property>
using System;
using System.Linq;
using System.Xml.Linq;
class Program
{
static void Main(string[] args)
{
string targetPropertyKey = "NCE10000"; // 目标属性键
string targetLanguage = "en"; // 目标语言
// 加载XML文件
XDocument doc = XDocument.Load("your_xml_file.xml");
// 选择特定属性键和语言下的多语言信息
var values = from property in doc.Descendants("property")
where (string)property.Attribute("key") == targetPropertyKey
from value in property.Elements("value")
where (string)value.Attribute("lang") == targetLanguage
select (string)value;
// 输出结果
Console.WriteLine($"Values for Property Key: {targetPropertyKey}, Language: {targetLanguage}");
foreach (var value in values)
{
Console.WriteLine($"Text: {value}");
}
}
}
LINQ 很酷 像是在做DB工作 方便好用
Comments | NOTHING