Hi,
I've got no errors for compiling but I can't figure out why there isn't any stored output when I save them into a XML file.
thanks!
Current output
Wanted outputCode:<?xml version="1.0" encoding="utf-8" ?> <AirlineArray xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xsi:nil="true" />
------------------------------------------------------------------------------------------------Code:<?xml version="1.0" encoding="utf-8"?> <AirlineArray xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema"> <airlineList> <RFQSave> <quotationId>1234</quotationId> <supplier>1301</supplier> <prodName>Singapore Airline</prodName> <classType>Economy Class</classType> <adultQuantity>4</adultQuantity> <childQuantity>4</childQuantity> </RFQSave> </airlineList> </AirlineArray>
Array to store RFQSave
RFQSaveCode:public class AirlineArray { public RFQSave[] airlineList; }
Main codeCode:public class RFQSave { public string quotationId; public string supplier; public string prodName; public string classType; public string adultQuantity; public string childQuantity; public RFQSave(string nid, string nsupplier, string nprodName, string nclassType, string nadultAmt, string nchildAmt) { quotationId = nid; supplier = nsupplier; prodName = nprodName; classType = nclassType; adultQuantity = nadultAmt; childQuantity = nchildAmt; } public RFQSave() { } }
Code:public partial class _Default : System.Web.UI.Page { private int counter; private AirlineArray airline; private RFQSave airSave; protected void Page_Load(object sender, EventArgs e) { airline = new AirlineArray(); counter = 0; } protected void btnStore_Click(object sender, EventArgs e) { if (ddlAirline.SelectedValue == "1301") { tbxName.Text = "Singapore Airline"; lblWarning.Text = ""; airSave = new RFQSave(tbxQuotationID.Text, ddlAirline.Text, tbxName.Text, ddlClass.Text, tbxdoulePrice.Text, tbxSingleQuantity.Text); //add airSave to the Airline RFQ RFQSave[] temp = new RFQSave[counter + 1]; for (int i = 0; i < counter; i++) { temp[i] = airline.airlineList[i]; } temp[counter] = airSave; counter++; airline.airlineList = temp; lblWarning.Text = "Sinagpore Airline Quotation Stored, ready for export!"; } } protected void btnSave_Click(object sender, EventArgs e) { XmlWriterSettings settings = new XmlWriterSettings(); settings.Indent = true; XmlWriter wrt = XmlWriter.Create("D://AirlineRFQ.xml", settings); XmlSerializer serializer = new XmlSerializer(typeof(AirlineArray)); serializer.Serialize(wrt, airline); wrt.Close(); lblWarning.Text = "Airline Quotation XML exported!"; } }




Reply With Quote