我是在 C# 中查询 XML 文件的新手。任何帮助,将不胜感激。提前致谢..
我有这个 XML 文件:
<Point>
<Statement>
<Type />
<FullCondtion />
<ExpressionList />
</Statement>
<TestList>
<Test>
<Inputs>
<Variable Name="u1_count" Value="0" />
<Variable Name="u1_flag" Value="2" />
<Variable Name="ON" Value="1" />
<Variable Name="OFF" Value="0" />
<Variable Name="u1_ch" Value="0" />
<Variable Name="u1_index" Value="3" />
</Inputs>
<Outputs>
<Variable Name="u1_count" Value="0" />
<Variable Name="u1_flag" Value="0" />
<Variable Name="ON" Value="1" />
<Variable Name="OFF" Value="0" />
<Variable Name="u1_ch" Value="0" />
<Variable Name="u1_index" Value="0" />
</Outputs>
</Test>
<Test>
<Inputs>
<Variable Name="u1_count" Value="0" />
<Variable Name="u1_flag" Value="2" />
<Variable Name="ON" Value="1" />
<Variable Name="OFF" Value="0" />
<Variable Name="u1_ch" Value="0" />
<Variable Name="u1_index" Value="3" />
</Inputs>
<Outputs>
<Variable Name="u1_count" Value="0" />
<Variable Name="u1_flag" Value="0" />
<Variable Name="ON" Value="1" />
<Variable Name="OFF" Value="0" />
<Variable Name="u1_ch" Value="0" />
<Variable Name="u1_index" Value="0" />
</Outputs>
</Test>
</TestList>
<TestList>
<Test>
<Inputs>
<Variable Name="u1_count" Value="0" />
<Variable Name="u1_flag" Value="2" />
<Variable Name="ON" Value="1" />
<Variable Name="OFF" Value="0" />
<Variable Name="u1_ch" Value="0" />
<Variable Name="u1_index" Value="3" />
</Inputs>
<Outputs>
<Variable Name="u1_count" Value="0" />
<Variable Name="u1_flag" Value="0" />
<Variable Name="ON" Value="1" />
<Variable Name="OFF" Value="0" />
<Variable Name="u1_ch" Value="0" />
<Variable Name="u1_index" Value="0" />
</Outputs>
</Test>
<Test>
<Inputs>
<Variable Name="u1_count" Value="0" />
<Variable Name="u1_flag" Value="2" />
<Variable Name="ON" Value="1" />
<Variable Name="OFF" Value="0" />
<Variable Name="u1_ch" Value="0" />
<Variable Name="u1_index" Value="3" />
</Inputs>
<Outputs>
<Variable Name="u1_count" Value="0" />
<Variable Name="u1_flag" Value="0" />
<Variable Name="ON" Value="1" />
<Variable Name="OFF" Value="0" />
<Variable Name="u1_ch" Value="0" />
<Variable Name="u1_index" Value="0" />
</Outputs>
</Test>
</TestList>
</Point>
</Pattern>
</CodeAnalyzerResults>
我需要将输入和输出中的变量及其值写入如下表中:
输入
u1_count 0 0 0 0
u1_flag 2 2 2 2
...
u1_index 3 3 3 3
输出也是如此。如何获取每个变量的输入和输出值并将它们连续写入?
我读了这篇文章:http ://www.c-sharpcorner.com/uploadfile/dhananjaycoder/reading-xml-file-through-linq-a-few-tips/但我仍然想不出办法..