hi
i have two class foo and wrappers
foo is my original class and i create a list from foo class
and wrappers class decorate with [serializable] and [xmlelement(ElementName=)]
this is my foo class
public class foo
{
public string Name { get; set; }
public string Family { get; set; }
public int ID { get; set; }
}
and this is my wrappers class
[Serializable]
public class wrappers
{
[XmlElement(ElementName = "FirstName")]
public string Name { get; set; }
[XmlElement(ElementName = "LastName")]
public string Family { get; set; }
[XmlElement(ElementName = "BranchCode")]
public int ID { get; set; }
}
when i use decorate like above custome xml is
<?xml version="1.0"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wrappers>
<FirstName>Ali</FirstName>
<LastName>Shahmohammadi</LastName>
<BranchCode>1</BranchCode>
</wrappers>
<wrappers>
<FirstName>Hossein</FirstName>
<LastName>Shahmohammadi</LastName>
<BranchCode>2</BranchCode>
</wrappers>
</Root>
but when i use decorate like this for wrappers class
[Serializable]
public class wrappers
{
[XmlElement(ElementName = "101")]
public string Name { get; set; }
[XmlElement(ElementName = "102")]
public string Family { get; set; }
[XmlElement(ElementName = "103")]
public int ID { get; set; }
}
custome xml tag is not currrect display and custome xml tag is
<?xml version="1.0"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wrappers>
<_x0031_01>Ali</_x0031_01>
<_x0031_02>Shahmohammadi</_x0031_02>
<_x0031_03>1</_x0031_03>
</wrappers>
<wrappers>
<_x0031_01>Hossein</_x0031_01>
<_x0031_02>Shahmohammadi</_x0031_02>
<_x0031_03>2</_x0031_03>
</wrappers>
</Root>
and i want have custome xml like
<?xml version="1.0"?>
<Root xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema">
<wrappers>
<101>Ali</101>
<102>Shahmohammadi</102>
<103>1</103>
</wrappers>
<wrappers>
<101>Hossein</101>
<102>Shahmohammadi</102>
<103>2</103>
</wrappers>
</Root>
What I have tried:
to create xml and use it on my application