I know how to serialize an xml. But this following example I have never done yet. And I can’t figure out how to do it either.
<Products>
<row **id="10"**>
<ProductName>Cola</ProductName>
<Amount>3</Amount>
</row>
<row **id="20"**>
<ProductName>Fanta</ProductName>
<Amount>6</Amount>
</row>
</Products>
So I want use xml serialization, most of the xml is done, but this little part of it remains.
I can’t manage to put the id behind the row. I bet I need to use xmlattribute but I don’t really know how to implement.
Can someone please help me out on how to get the id in “Row” element with xml serialization specifically.
(I did find some way to do it with another way, but since this XML is pretty large and most of it I finished so I would love to continue. And also don’t want to go around any little problem.)
You just need to create an ID member in your class and then mark it with the
XmlAttributeattribute, for instance: