c# - XML Deserialization not deserializing element -


good afternoon,

i have following classes

public class maintenancebundle {     [xmlattribute(attributename = "required")]     public string required { get; set; }      [xmlattribute(attributename = "id")]     public string id { get; set; }      [xmlelement(elementname = "title")]     public string title { get; set; }      [xmlelement(elementname = "mntreason")]     public maintenancereason reason { get; set; }      [xmlelement(elementname = "tasks")]     public maintenancebundlecollection tasks { get; set; } }  public class maintenancebundlecollection {     [xmlelement(elementname = "task")]     public list<maintenancebundletask> tasks { get; set; } }  public class maintenancereason {     [xmlattribute(attributename = "every")]     public string every { get; set; }      [xmlelement(elementname = "mileage", isnullable = true)]     public int? mileage { get; set; }      [xmlelement(elementname = "time", isnullable = true)]     public timeinterval timeinterval { get; set; } } 

i'm trying deserialize xml objects using these classes. here xml

<mntbundle required="yes" id="s08870641702009101200000">     <title>dirt or dusty roads - 5000 miles / 6 months</title>     <mntreason every="no">       <mileage unit="miles">5000</mileage>     </mntreason>     <tasks>       <task id="4-2" />       <task id="4-3">         <nmvcqualifier>drive shaft boots</nmvcqualifier>         <mvcqualifiers>           <qualifier name="drive type">4wd</qualifier>         </mvcqualifiers>       </task>       <task id="4-1" />       <task id="4-4" />       <task id="5-1">         <mvcqualifiers>           <qualifier name="drive type">4wd</qualifier>         </mvcqualifiers>       </task>       <task id="6-1" />       <task id="7-1" />     </tasks>   </mntbundle> 

for reason unable mileage element inside mntreason element. keeps coming null. ideas doing wrong? other elements seem deserialize properly. left out irrelevant classes post. if has pointers how can retreive value love hear it. help.

cheers,
~ck in san diego

untested should need class below. i'm not sure how xmltext behave integer.

public class mileage {    [xmlattribute(attributename = "unit")]    public string unit {get; set;}     [xmltext]    public int mileage {get; set;} } 

Comments

Popular posts from this blog

python - Scipy curvefit RuntimeError:Optimal parameters not found: Number of calls to function has reached maxfev = 1000 -

c# - How to add a new treeview at the selected node? -

java - netbeans "Please wait - classpath scanning in progress..." -