.NET XML newbie question
My Code segment (not complete):
xmlW.Formatting = Formatting.Indented;
xmlW.WriteStartDocument(true);
xmlW.WriteStartElement("Transactions");
xmlW.WriteStartElement("Transaction");
xmlW.WriteElementString("Type", "A");
xmlW.WriteElementString("ID", XmlConvert.ToString(OrderNumber));
xmlW.WriteElementString("Amount", XmlConvert.ToString(OrderTotal));
xmlW.WriteElementString("Currency", Common.StoreCurrency());
xmlW.WriteStartElement("CreditCard");
xmlW.WriteElementString("OwnerName", Billing.firstName + " " + Billing.lastName);
xmlW.WriteElementString("OwnerAddress", Billing.address1);
xmlW.WriteElementString("OwnerPostal", Billing.zip);
xmlW.WriteElementString("OwnerCity", Billing.city);
xmlW.WriteElementString("OwnerCountry", Billing.country);
xmlW.WriteElementString("Number", CardNumber);
xmlW.WriteElementString("CVC", CardExtraCode);
xmlW.WriteStartElement("ValidThru");
xmlW.WriteElementString("Month", CardExpirationMonth.PadLeft(2,'0'));
xmlW.WriteElementString("Year", CardExpirationYear);
xmlW.WriteEndElement();
xmlW.WriteEndElement();
xmlW.WriteEndElement();
This produces the following XML file (Not complete):
<?xml version="1.0" standalone="yes"?>
<Transactions>
<Transaction>
<Type>A</Type>
<ID>123</ID>
<Amount>10.99</Amount>
<Currency>USD</Currency>
<CreditCard>
<OwnerName>John Doe</OwnerName>
<OwnerAddress>11 Second street</OwnerAddress>
<OwnerPostal>11322</OwnerPostal>
<OwnerCity>City of dust</OwnerCity>
<OwnerCountry>USA</OwnerCountry>
<Number>1234567890123456</Number>
<CVC>123</CVC>
<ValidThru>
<Month>12</Month>
<Year>2004</Year>
</ValidThru>
</CreditCard>
</Transaction>
</Transactions>
My client's required document format is (Notice that there is no "</CreditCard>" end element):
<?xml version="1.0" standalone="yes"?>
<Transactions>
<Transaction>
<Type>A</Type>
<ID>123</ID>
<Amount>10.99</Amount>
<Currency>USD</Currency>
<CreditCard>
<OwnerName>John Doe</OwnerName>
<OwnerAddress>11 Second street</OwnerAddress>
<OwnerPostal>11322</OwnerPostal>
<OwnerCity>City of dust</OwnerCity>
<OwnerCountry>USA</OwnerCountry>
<Number>1234567890123456</Number>
<CVC>123</CVC>
<ValidThru>
<Month>12</Month>
<Year>2004</Year>
</ValidThru>
</Transaction>
</Transactions>
My problem is that the Client's requirement does not include an end tag for the element "<CreditCard>". How can I achieve this, still conforming to the XML standard and keeping the indentation as well? Any help is highly appreciated.

