c# - Proper usage of XMLRootAttribute in Monotouch -


i have class called school serializable. when serializes/deserializes need root element called school not school without having change class name school. used xmlroot attribute in following way:

[xmlroot(elementname = "school")]

i tried:

[xmlroot("school")]

neither of these did , resulting xml file contained root element called school.

am missing something?

i not see problem following code works monotouch 4 (maybe you'll find difference between , own code).

i defined class like:

[xmlroot ("school")] public class wrong {     public string name { get; set; } } 

then serialized memorystream read string.

        wrong bad = new wrong ();         xmlserializer ser = new xmlserializer(typeof(wrong));         using (memorystream ms = new memorystream ()) {             ser.serialize (ms, bad);             ms.position = 0;             streamreader sr = new streamreader (ms);             string st = sr.readtoend ();         } 

the value of 'st' is:

<?xml version="1.0" encoding="utf-8"?> <school xmlns:xsi="http://www.w3.org/2001/xmlschema-instance" xmlns:xsd="http://www.w3.org/2001/xmlschema" /> 

Comments

Popular posts from this blog

apache - Add omitted ? to URLs -

redirect - bbPress Forum - rewrite to wwww.mysite prohibits login -

php - How can I stop spam on my custom forum/blog? -