다음과 같은 XML이 있습니다. 이것을 C# 객체로 변환하고 싶습니다. 나는 modyfying을 시도했지만 작동시키지 못했습니다.개체에 XML 비 직렬화가 작동하지 않습니다.
<SLVGeoZone-array>
<SLVGeoZone>
<id>19</id>
<type>geozone</type>
<name>60_OLC_SC</name>
<namesPath>GeoZones/60_OLC_SC</namesPath>
<idsPath>1/19</idsPath>
<childrenCount>0</childrenCount>
</SLVGeoZone>
</SLVGeoZone-array>
나는이 서면 샘플 C# 코드와는 작동하지 않습니다
[Serializable]
public class SLVGeoZone
{
[XmlElement("id")]
public string id { get; set; }
[XmlElement("type")]
public string type { get; set; }
[XmlElement("name")]
public string name { get; set; }
[XmlElement("namespath")]
public string namespath { get; set; }
[XmlElement("idspath")]
public string idspath { get; set; }
[XmlElement("childrencount")]
public string childrencount { get; set; }
}
[Serializable]
[XmlRoot("SLVGeoZone-array")]
public class SLVGeoZone-array
{
[XmlArray("SLVGeoZone-array")]
[XmlArrayItem("SLVGeoZone", typeof(SLVGeoZone))]
public SLVGeoZone[] Car { get; set; }
}
그리고 형태
:XmlSerializer serializer = new XmlSerializer(typeof(CarCollection));
StreamReader reader = new StreamReader(path);
cars = (CarCollection)serializer.Deserialize(reader);
reader.Close();
누군가가 내가 뭘 잘못 제안 할 수 있습니까?
당신은 "작동하지 않습니다"무엇을 의미합니까? 예외가 발생합니까? 빈 객체를 반환합니까? 엘더 차원에서 말로 표현할 수없는 공포가 뒤틀린다고? – Aron