title: C# Pass multiple parameters into XML using Queue
body: <p>I have a webservice that obtains data from Oracle CRM OnDemand. I want to create another WS that takes the fields for a given customer record and passes those fields as parameters into an XML writer which then creates the XML to be passed to another webservice (being developed by another team).</p>
  
  <p>I can create the XML fine and pass the parameters. However, I am only testing 3-4 fields and passing them. I will need way more than 4 parameters to be passed, and I know this is pretty poor programming to create a function that takes 3+ parameters. (EDIT) I have created a queue that takes in the parameters from the page, and I pass just the queue. I want to dequeue the data field followed by a string of what I want to pass into the XML page. </p>
  
  <p>This is what I have right now. </p>
  
  <pre><code>...for (int intIndx = 0; intIndx &lt; intCount; intIndx++)
                      {
                          //Create queue to store all the data obtained from a given Account
                          Queue&lt;string&gt; q = new Queue&lt;string&gt;();
                          //Easier to reference 
                          var acctName=  objAcctQryOut.ListOfAccount[intIndx].AccountName;
                          var acctWebsite = objAcctQryOut.ListOfAccount[intIndx].WebSite;
                          q.Enqueue(acctName);                            
                          addyInsert.CountryCode = objAcctQryOut.ListOfAccount[intIndx].PrimaryBillToCountry;
                          q.Enqueue(addyInsert.CountryCode);
                          addyInsert.Line1 = objAcctQryOut.ListOfAccount[intIndx].PrimaryBillToStreetAddress;
                          q.Enqueue(addyInsert.Line1);
                          addyInsert.Line2 = accountInfo.PrimaryBillToStreetAddress2;
                          q.Enqueue(addyInsert.Line2);
                          addyInsert.Line3 = accountInfo.PrimaryBillToStreetAddress3;
                          q.Enqueue(addyInsert.Line3);
                          addyInsert.City = objAcctQryOut.ListOfAccount[intIndx].PrimaryBillToCity;
                          q.Enqueue(addyInsert.City);
                          addyInsert.CountyCodeVertex = accountInfo.PrimaryBillToCounty;
                          q.Enqueue(addyInsert.CountyCodeVertex);
                          addyInsert.StateProvinceCodeVertex = accountInfo.PrimaryBillToState;
                          q.Enqueue(addyInsert.StateProvinceCodeVertex);even know? 
                          custResponse.CustomerNumber = accountInfo.FuriganaName;
                          q.Enqueue(custResponse.CustomerNumber);
                          custInput.BillingCurrency = accountInfo.CurrencyCode;
                          q.Enqueue(custInput.BillingCurrency);
                          custInput.Email = accountInfo.CustomText1;
                          q.Enqueue(custInput.Email);
                          custInput.TravelPortCustomerTypeCode = accountInfo.AccountType;
                          q.Enqueue(custInput.TravelPortCustomerTypeCode);
                          var count = q.Count;
  
                          var xml = new XML();
                          xml.sendAccountInfoXML(q);
                          //xml.sendAccountInfoXML(acctName, addyInsert.CountryCode, addyInsert.Line1, addyInsert.Line2, addyInsert.Line3, acctWebsite);
  
                      }
  
  private void createXML(Queue&lt;string&gt; q)
          {
              string saveLoc = @"C:\Users\XML Test\test{0}.xml";
              XmlTextWriter writer = new XmlTextWriter(saveLoc, System.Text.Encoding.UTF8);
              XmlDocument doc = new XmlDocument();
              writer.WriteStartDocument(true);
              writer.Formatting = Formatting.Indented;
              writer.Indentation = 2;
              writer.WriteStartElement("HEADER");
              createNode(q, writer);
              writer.WriteEndElement();
              writer.WriteEndDocument();
              writer.Close();
              doc.Save(writer);
          }
  private void createNode(Queue&lt;string&gt; q, XmlWriter writer)
          {
              Queue&lt;string&gt; x = new Queue&lt;string&gt;();
              x.Enqueue("ACCOUNTNAME");
              x.Enqueue("BILLINGCOUNTRY");
              x.Enqueue("BILLINGLINE1");
              x.Enqueue("BILLINGLINE2");
              x.Enqueue("BILLINGLINE3");
              x.Enqueue("BILLINGCITY");
              x.Enqueue("BILLINGCOUNTY");
              x.Enqueue("BILLINGSTATE");
              x.Enqueue("CUSTOMERNUMBER");
              x.Enqueue("BILLINGCURRENCY");
              x.Enqueue("CUSTOMEREMAIL");
              x.Enqueue("CUSTOMERTYPE");
              //x.Enqueue("CUSTOMURL");
              writer.WriteStartElement("ACCOUNTINFO");
              for (int i = 0; i &lt; x.Count; i++)
              {
                  writer.WriteStartElement(x.Dequeue());
                  for (int j = 0; j &lt; q.Count; j++)
                  {
                      writer.WriteString(q.Dequeue());
                      writer.WriteEndElement();
                  }
              }
              writer.WriteEndElement();
          }
  </code></pre>
  
  <p>However, I feel that the nested loops are not properly functioning. Would you mind trying to guide me through it and point out where I'm messing up? Thank you. </p>