Your xml become sensitive to big and small letters, so say
<myclass>
<myproperty>1</myproperty>
</myclass>
is not
public class MyClass{
public int MyProperty{ get;set;}
}
rather would be
public class myclass{
public int myproperty{ get;set;}
}
so what you need to do is match the way you wrote it
... (updating solution) ...
So if that doesn't work, i suggest going the other way about. Make the class first
and it is clear by observing your xml that a class AdviceTag could be generated with two simply types and one complex type called Acy with two values (Blocked and amount), perhaps like this:
public class AdviceTag
{
public string AClassName { get; set; }
public string BlockedBalance { get; set; }
public Acy Acy { get; set; }
}
public class Acy
{
public string Blocked{ get; set; }
public string Amount { get; set; }
}
so that in place let's simply generate the xml by instantiating an instance of that class and serialize it
var aTag = new AdviceTag { AClassName = "Sav1 Account", BlockedBalance = "0", Acy = new Acy { Amount = "56", Blocked = "23" } };
var ser = new XmlSerializer(typeof(AdviceTag));
string filename = Assembly.GetExecutingAssembly().Location;
int pos = filename.LastIndexOf(@"\");
filename = filename.Substring(0, pos +1) + "myfile.xml";
using(var fs = new FileStream(filename, FileMode.Create, FileAccess.Write))
{
ser.Serialize(fs, aTag);
fs.Flush();
fs.Close();
}
We're placing the serialized xml in same location as executing assembly and calling it myfile.xml, it then looks like this:
="1.0"
<AdviceTag xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<AClassName>Sav1 Account</AClassName>
<BlockedBalance>0</BlockedBalance>
<Acy>
<Blocked>23</Blocked>
<Amount>56</Amount>
</Acy>
</AdviceTag>
And now what was the mistake?
Well your xml designates a complex type called acy containing two member properties, but you were struggleing to put them in an arraylist, where you don't have to.