.NET XML newbie question

Hi, I have the following code that produces an xml doc. My problem is, the Client's requirement for this xml doc is slightly different. Can somene please tell me how to write out this doc exactly as the client requirement? I am fairly new to this XML stuff. Any help is highly appreciated.

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.
[3682 byte] By [babuman] at [2007-11-19 2:42:21]
# 1 Re: .NET XML newbie question
? Your client's data model is not valid xml. You can't conform to xml if you're not conforming to it. So you can't do this with an XML writer.

Perhaps they wanted an empty <CreditCard/> tag? [in which case you'd put the xmlW.WriteEndElement(); after xmlW.WriteStartElement("CreditCard");]
Maybe the end tag was stripped out, much like <br/>'s turn to <br> in html.

Only advice I can give is to clarify this with your client; they probably sent you bad information.

Sorry if this doesn't help.
jkmyoung at 2007-11-10 3:27:52 >