I need to generate an XML document that follows this specifictaion
<productName locale="en_GB">Name</productName> but using XMLSeralization I am getting the following
<productName locale="en_GB"> <Name>Name</Name> </productName> My C# code is like this:
[Serializable] public class productName { public productName() { } public string Name; [XmlAttribute] public string locale; } XmlAttribute is what is required to show the locale in the correct place, but I am unable to figure out how to export the Name field correctly.
Does anyone have an idea?
Thanks
EDIT:
This is the code to generate the XML
public static class XMLSerialize { public static void SerializeToXml<T>(string file, T value) { var serializer = new XmlSerializer(typeof(T)); using (var writer = XmlWriter.Create(file)) serializer.Serialize(writer, value); } public static T DeserializeFromXML<T>(string file) { XmlSerializer deserializer = new XmlSerializer(typeof(T)); TextReader textReader = new StreamReader(file); T result; result = (T)deserializer.Deserialize(textReader); textReader.Close(); return result; } }