title: C# XML Serialization XMLElement Path
body: <p>i am currently working on a project where i need the c# Xml Serialization.</p>
  
  <p>My Problem:
  I havea class called ClassA. It has a Name Property which i would like to serialize in the Xml-File.</p>
  
  <pre><code> public class ClassA : BaseClass
  {
      [XmlElement("name")]
      public string Name
      {
          get { return GetProperty(() =&gt; Name); }
          set { SetProperty(() =&gt; Name, value); }
      }
  }
  </code></pre>
  
  <p>So when i serialize this with this serializer</p>
  
  <pre><code>public class PetriNetXMLReader
  {
      public void SaveToXML(PetriNetXML petriNet, string fileName)
      {
          System.Xml.Serialization.XmlSerializer writer =
         new System.Xml.Serialization.XmlSerializer(typeof(PetriNetXML));
  
             System.IO.FileStream file = System.IO.File.Create(fileName);
  
          writer.Serialize(file, petriNet);
          file.Close();
      }
  
      public PetriNetXML ReadFromXML(string fileName)
      {
          var fileStream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
  
          XmlSerializer deserializer = new XmlSerializer(typeof(PetriNetXML));
          return (PetriNetXML)deserializer.Deserialize(fileStream);
  
  
  
      }
  }
  </code></pre>
  
  <p>i get a xml-file like this</p>
  
  <pre><code>&lt;ClassA Id="5eda8e4c-0698-4e07-9d20-7985964786f9" &gt;
    &lt;name&gt;Description&lt;/name&gt;
  &lt;/ClassA&gt;
  </code></pre>
  
  <p>So my Question:
  I would like to have a xml like</p>
  
  <pre><code> &lt;ClassA Id="5eda8e4c-0698-4e07-9d20-7985964786f9" &gt;
    &lt;name&gt;&lt;text&gt;Description&lt;/text&gt;&lt;/name&gt;
  &lt;/ClassA&gt;
  </code></pre>
  
  <p>How can i make this? I dont want to create a new class for the Name-Property..</p>
  
  <p>Thanks :)</p>