compact framework - XmlRoot attribute c# -


i'm in need serialize string valid xml object. thing object 2 arrays of other objects, , don't know if following annotation correct:

[xmlroot("data")] public class data {     [xmlarray("servicourgente")]     public servicourgente[] servicosurgentes;      [xmlarray("mensagem")]     public mensagem[] mensagens; }   [xmlroot("mensagem")] public class mensagem {     [xmlelement("touserid")]     public int touserid;      [xmlelement("message")]     public int message;      [xmlelement("timestamp")]     public datetime timestamp;  }   [xmlroot("servicourgente")] public class servicourgente {     [xmlelement("servicoid")]     public int servicoid;     [xmlelement("touserid")]     public int touserid;      [xmlelement("fromuserid")]     public int fromuserid;     [xmlelement("fromusername")]     public string fromusername;      [xmlelement("datainicioprevista")]     public datetime datainicioprevista;     [xmlelement("datafimprevista")]     public datetime datafimprevista;      [xmlelement("idpoi")]     public int idpoi;     [xmlelement("nomepoi")]     public string nome;     [xmlelement("descricaopoi")]     public string descricao;     [xmlelement("ncontratopoi")]     public string ncontrato;     [xmlelement("moradapoi")]     public string morada;     [xmlelement("latitudepoi")]     public double latitude;     [xmlelement("longitudepoi")]     public double longitude;  } 

the questions is: have each class xmlroot attribute, or data class has it, , other 2 have attribute instead of xmlroot

xmlroot going if object ends root element of serialized file. does not affect how objects named inside arrays (as far know).

to set names of arrays , objects inside use respective attributes:

[xmlarray("nameofelementwrappingtheitems")] [xmlarrayitem("nameofitemsinsidethearray")] public object[] stuff ... 

we cannot know if code correct if don't post xml should translate or read from.


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..." -