This project is read-only.
Specifying that a field or property should be serialized as an attribute is incredibly simple. By decorating that field/property with an XmlAttribute attribute the serializer will output the value as an attribute. You may specify a new name for the attribute at the same time. below is an example class.
class User
   [XmlAttribute] string Name { get; set; }
   [XmlIgnore] string Password { get; set; }
   [XmlAttribute] string Domain { get; set; }
   [XmlAttribute("Dept")] string Department { get; set; }   
   string Background { get; set; }
The serialized output of an example instance of the class above might look something like the following:
<?xml version="1.0" encoding="utf-16"?>
<User Name="Joe Thomas" Domain="" Dept="Finance">
   <Background>Some generic text</Background>

Last edited Feb 1, 2015 at 7:19 AM by WiredWiz, version 2