title: How can I get XmlSerializer to encode bools as yes/no?
body: <p>I'm sending xml to another program, which expects boolean flags as "yes" or "no", rather than "true" or "false".</p>
  
  <p>I have a class defined like:</p>
  
  <pre><code>[XmlRoot()]
  public class Foo {
      public bool Bar { get; set; }
  }
  </code></pre>
  
  <p>When I serialize it, my output looks like this:</p>
  
  <pre><code>&lt;Foo&gt;&lt;Bar&gt;true&lt;/Bar&gt;&lt;/Foo&gt;
  </code></pre>
  
  <p>But I would like it to be this:</p>
  
  <pre><code>&lt;Foo&gt;&lt;Bar&gt;yes&lt;/Bar&gt;&lt;/Foo&gt;
  </code></pre>
  
  <p>Can I do this at the time of serialization? I would prefer not to have to resort to this:</p>
  
  <pre><code>[XmlRoot()]
  public class Foo {
      [XmlIgnore()]
      public bool Bar { get; set; }
  
      [XmlElement("Bar")]
      public string BarXml { get { return (Bar) ? "yes" : "no"; } }
  }
  </code></pre>
  
  <p>Note that I also want to be able to <em>deserialize</em> this data back again.</p>