xml parsing - How to Deserialize XML Array items? -


i having trouble deserializing xml. accountinformation work wont work leauge elements. xml doesnt contain tag "leauges" , dont want add tag work. there other way "fix" it? have tried diffrent solutions deserialized result of leauges comes empty. missing?

any appreciated!

se code below:

update:

i have modified code , xml wont work anyway. waht missing here?

[serializable] [xmlroot(elementname = "leaugecollection", namespace = "")] public class leaguecollection {     [xmlarray("leagues")]     [xmlarrayitem("league",typeof(league))]     public  league[] league { get; set; }      [xmlelement(elementname = "accountinformation")]     public string accountinformation { get; set; }  }  [serializable()] public class league {     [xmlelement(elementname = "id")]     public int id { get; set; }      [xmlelement(elementname = "name")]     public string name { get; set; }      [xmlelement(elementname = "country")]     public string country { get; set; }      [xmlelement(elementname = "historical_data")]     public string historical_data { get; set; }      [xmlelement(elementname = "fixtures")]     public string fixtures { get; set; }      [xmlelement(elementname = "livescore")]     public string livescore { get; set; }      [xmlelement(elementname = "numberofmatches")]     public int numberofmatches { get; set; }      [xmlelement(elementname = "latestmatch")]     public datetime latestmatch { get; set; } } 

deserialize code:

public static void main(string[] args)     {         xmlserializer deserializer = new xmlserializer(typeof(leaguecollection));          textreader reader = new streamreader(@"c:\xmlfiles\xmlsoccer.xml");         object obj = deserializer.deserialize(reader);         leaguecollection xmldata = (leaguecollection)obj;         reader.close();     } 

link xml:

thanksin advance!

the xml have in image missing actual array element (leauges), has array items elements (leauge), why cannot deserialized!

update: ok, trying reproduce code, see in xml elements spelled "league" while in code "leauge"

fix first!

update2: after edits have done according comments,it seems work fine!


Comments

Popular posts from this blog

python - pip install -U PySide error -

arrays - C++ error: a brace-enclosed initializer is not allowed here before ‘{’ token -

cytoscape.js - How to add nodes to Dagre layout with Cytoscape -