Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/xml/14.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/oop/2.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C#使用队列将多个参数传递到XML中_C#_Xml_List_For Loop_Parameters - Fatal编程技术网

C#使用队列将多个参数传递到XML中

C#使用队列将多个参数传递到XML中,c#,xml,list,for-loop,parameters,C#,Xml,List,For Loop,Parameters,我有一个从Oracle CRM OnDemand获取数据的Web服务。我想创建另一个WS,它接受给定客户记录的字段,并将这些字段作为参数传递给XML编写器,然后XML编写器创建要传递给另一个Web服务(由另一个团队开发)的XML 我可以很好地创建XML并传递参数。然而,我只测试了3-4个字段并通过了测试。我需要传递4个以上的参数,我知道创建一个包含3个以上参数的函数的编程非常糟糕。(编辑)我创建了一个队列,该队列接收页面中的参数,我只传递队列。我想在数据字段的后面加上一个字符串,该字符串是我想传

我有一个从Oracle CRM OnDemand获取数据的Web服务。我想创建另一个WS,它接受给定客户记录的字段,并将这些字段作为参数传递给XML编写器,然后XML编写器创建要传递给另一个Web服务(由另一个团队开发)的XML

我可以很好地创建XML并传递参数。然而,我只测试了3-4个字段并通过了测试。我需要传递4个以上的参数,我知道创建一个包含3个以上参数的函数的编程非常糟糕。(编辑)我创建了一个队列,该队列接收页面中的参数,我只传递队列。我想在数据字段的后面加上一个字符串,该字符串是我想传递到XML页面的内容

这就是我现在拥有的

...for (int intIndx = 0; intIndx < intCount; intIndx++)
                    {
                        //Create queue to store all the data obtained from a given Account
                        Queue<string> q = new Queue<string>();
                        //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<string> 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<string> q, XmlWriter writer)
        {
            Queue<string> x = new Queue<string>();
            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 < x.Count; i++)
            {
                writer.WriteStartElement(x.Dequeue());
                for (int j = 0; j < q.Count; j++)
                {
                    writer.WriteString(q.Dequeue());
                    writer.WriteEndElement();
                }
            }
            writer.WriteEndElement();
        }
…for(intintindx=0;intIndx

但是,我觉得嵌套循环没有正常工作。你介不介意引导我通过它,并指出我在哪里搞砸了?多谢各位

您可以只接受一个
IDictionary
ILookup
并将其中的任何内容放入XML中…
ILookup
用于将键映射到枚举,而不是单个值
IDictionary
可能是合适的,但是这里有太多不同的选项来避免这个问题过于宽泛。就创建XML而言,您可能会发现使用
XmlDocument
XDocument
更容易,它们都提供了完整的“文档对象模型”来生成XML,而不是基于线性编写器的方法。因此,XML序列化可能是最方便的方法。但这个问题不够具体,无法用一种非宽泛的方式来解决。@PeterDuniho您还需要什么其他细节?我想到了将每个CRM字段存储为队列中的一项,然后传递qu