日期:2014-05-17 浏览次数:20437 次
string orderNo = this.IndexwaybillNo.Value; string clientId = "abc"; string logisticProviderID = "cbc"; string xml = ""; string[] rs = orderNo.Split('/'); xml = "<BatchQueryRequest>" + "<logisticProviderID>" + logisticProviderID + "</logisticProviderID>" + "<clientID>" + clientId + "</clientID>" + "<orders>" + "</orders>" + "</BatchQueryRequest>"; foreach (string s in rs) { if (s.Length < 10 || !IsNumberic(s)) { this.lblTime.Text = ""; Common.Alert("运单号输入不正确,请输入10位正确运单号"); } else { orderNo = s; XmlDocument xmlDoc = new XmlDocument(); xmlDoc.LoadXml(xml); XmlNode xmlNode = xmlDoc.SelectSingleNode("BatchQueryRequest/orders"); if (xmlNode != null) { XmlElement newElement = xmlDoc.CreateElement("order");//添加order节点 XmlElement etitle = xmlDoc.CreateElement("mailNo"); //添加mailNo节点 etitle.InnerText = orderNo.ToString(); //Common.Alert(etitle); newElement.AppendChild(etitle); xmlNode.AppendChild(newElement); } xmlDoc.Save(xml); } }
<BatchQueryRequest> <logisticProviderID>cbc</logisticProviderID> <clientID>abc</clientID> <orders> <order> <mailNo>1000000001</mailNo> </order> <order> <mailNo>1000000002</mailNo> </order> <order> <mailNo>1000000003</mailNo> </order> </orders> </BatchQueryRequest>