0
こんにちは。私のXMLからatribute環境をフィルタリングすることによって接続を取得したいです。 しかし、私はgettinいくつかのエラーが誰でも助けることができます。ここOpen XMLをLinqで開く方法
は私のコードです:
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:その後、あなたの結果では、あなたが「接続」タイプのXElementsのコレクションを持っています
そして:あなたはSelectManyを使用して、最初のコレクションを平らにする必要があります'{}'を使って問題のコードを作成しましたが、質問のタイトルに 'how'のスペルが間違っています – Jpsh
エラーは何ですか? – har07