title: Build XML Dynamically using c#
body: <p>I have to create an XML file dynamically based on the user input. </p>
  
  <p>Here is what I came up with and I am struck up with two issues.</p>
  
  <ol>
  <li>if there is a collection of same element (MaxOccurs = 10)
  (For example if the user entered 4 accounts then how should my code be)</li>
  <li>If there is a choice option. Based on the element chosen the child elements should change.</li>
  </ol>
  
  <p>Somebody please help me. </p>
  
  <p>Thanks in advance </p>
  
  <p>BB</p>
  
  <p>My code :</p>
  
  <pre><code>XElement req = 
      new XElement("order",
          new XElement("client", 
              new XAttribute("id", clientId),
              new XElement("quoteback", 
                  new XAttribute ("name",quotebackname)
                  )  
              ),
          new XElement("accounting",
              new XElement("account"),
              new XElement("special_billing_id")
              ),
          new XElement("products",
              new XElement(
                  **productChoiceType**,
                  ***** HERE THE ELEMENTS WILL CHAGE BASED ON  **productChoiceType**           
                  )
              )
          )
      );
  </code></pre>