0
您好,我想從我的xml 的屬性環境中獲取過濾器的連接,但即時通訊可以幫助您解決一些錯誤。如何使用Linq打開Open XML
這裏是我的代碼:
XElement xelement = XElement.Load(xml);
var Connections = from conn in xelement.Elements("Conections")
where (String)conn.Element("Conection").Attribute("Enviroment") == "Test"
select conn;
foreach (XElement conection in Connections)
{
MessageBox.Show(conection.Element("Conection").Value);
}
,這裏是我的XML
<?xml version="1.0" encoding="utf-8"?>
<Config>
<General>
<FormaInicial></FormaInicial>
<DiasRecordatorioBuro></DiasRecordatorioBuro>
<EnviarSMSDomiciliacion>rue</EnviarSMSDomiciliacion>
<SimularDeathLock></SimularDeathLock>
<IsProductionEnviroment></IsProductionEnviroment>
<WaitingTimeBetweenExecutions></WaitingTimeBetweenExecutions>
<NumberTriesBeforeRestartService></NumberTriesBeforeRestartService>
</General>
<Conections>
<Conection Enviroment="Production">
<Servidor></Servidor>
<BaseDatos>==</BaseDatos>
<Usuario></Usuario>
<Password></Password>
</Conection>
<Conection Enviroment="Test">
<Servidor></Servidor>
<BaseDatos></BaseDatos>
<Usuario></Usuario>
<Password></Password>
</Conection>
</Conections>
</Config>
請而非HTML/JavaScript的/ CSS有問題的代碼使用'{}',你在拼寫問題時也拼錯了'how' – Jpsh
究竟是什麼錯誤? – har07