日期:2014-05-17  浏览次数:20833 次

复杂格式的XML序列化
<?xml version="1.0"?>
<HotelGeos>
  <HotelGeoList>
    <HotelGeo Country="中国" ProvinceName="河北" ProvinceId="0500" CityName="南戴河" CityCode="0504">
      <Districts>
        <Location Id="0001" Name="海滨浴场"/>
      </Districts>
      <CommericalLocations>
        <Location Id="050402" Name="海滨地区"/>
      </CommericalLocations>
      <LandmarkLocations>
        <Location Id="0001" Name="南戴河"/>
      </LandmarkLocations>
    </HotelGeo>
    <HotelGeo Country="中国" ProvinceName="河北" ProvinceId="0500" CityName="邢台" CityCode="0505">
      <Districts>
        <Location Id="0001" Name="市中心"/>
      </Districts>
      <CommericalLocations>
        <Location Id="050501" Name="市中心"/>     
      </CommericalLocations>
      <LandmarkLocations>
        <Location Id="0001" Name="人民公园"/>
      </LandmarkLocations>
    </HotelGeo>
  </HotelGeoList>
</HotelGeos>
像这种复杂格式的XML 怎么序列化成  多个 List<t>

------解决方案--------------------
简单写了个,测试通过:


private void Button_Click_1(object sender, RoutedEventArgs e)
        {
            HotelGeos result = Deserialize < HotelGeos>(File.ReadAllText("XMLFile1.xml"));
        }