我有这个xml:
<?xml version="1.0" encoding="UTF-8"?>
<Dictionary>
<Object name="Ship">
<Struct_Name>tb_Ship</Struct_Name>
<Owner> ..... </Owner>
<Parameters>
<Parameter>
<Eng_Name>.....</Eng_Name>
<Discr>.....</Discr>
<Type>.....</Type>
</Parameter>
<Parameter>
<Eng_Name>......</Eng_Name>
<Discr>.........</Discr>
<Type>.................</Type>
</Parameter>
</Object>
<Object name="Car">
<Struct_Name>tb_Car</Struct_Name>
<Owner> ..... </Owner>
<Parameters>
<Parameter>
<Eng_Name>.....</Eng_Name>
<Discr>.....</Discr>
<Type>.....</Type>
</Parameter>
<Parameter>
<Eng_Name>......</Eng_Name>
<Discr>.........</Discr>
<Type>.................</Type>
</Parameter>
</Object>
</Dictionary>
我尝试像这样阅读这个xml:
foreach(var Object in Objects)
print the whole elements values
foreach(var Parameter in Parameters Of Current Object)
print the whole elements of current parameter
我尝试使用 2 foreach 并且它不工作总是得到异常对象未设置为类似这样的对象实例。有没有办法像我想要的那样读取这个 xml?