I have an XSD file and I used the xsd 2 code tool to generate the code for this XSD. When the XML file first create (before I give values) it contains some elements and values. My question is where does those values come from and how can I just start with empty elements.
Here is the code
private void XMLEF15ItemClick(object sender, ItemClickEventArgs e)
{
try
{
SaveFileDialog saveFile = new SaveFileDialog
{
FileName = "EF15 " + DefkCurrent.ArithmosAnaforas_7,
Filter = "XML (*.xml)|*.xml",
InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
};
EmcsMessage ecs = new EmcsMessage(DefkCurrent);
EF15 ef15Msg = ecs.CreateEF15();
if (saveFile.ShowDialog(this).Equals(DialogResult.OK))
{
ef15Msg.SaveToFile(saveFile.FileName);
MessageSuccess("ΔΕΦΚ - EF15");
}
}
catch (CreateMessageException ex)
{
using (DiskErrorsForm diskErrorsForm = new DiskErrorsForm(ex.Errors))
{
diskErrorsForm.ShowDialog(this);
}
}
}
Here is the EF15
private Defk DefkCurrent { get; set; }
private StringBuilder ErrorBuilder { get; set; }
private EF15AType MessageIF15 { get; set; }
public EF15(Defk defk)
{
DefkCurrent = defk;
MessageIF15 = new EF15AType();
LengthWarn.WarnBuilder = new StringBuilder();
}
public EF15.EF15 CreateEF15()
{
EF15.EF15 message = new EF15.EF15(DefkCurrent);
message.Create();
return message;
}
and here is the part of the generated code from XSD(IT is quite big to paste it all ,around 9000 lines)
public EF15AType() {
this.bodyField = new BodyType();
this.headerField = new HeaderType();
}
When code reach in EF15.EF15 message = new EF15.EF15(DefkCurrent); it already has create a part of the XML with this content (which I havent gave any values)
{<?xml version="1.0" encoding="utf-8"?>
<Header>
<DateOfPreparation xmlns="http://www.icisnet.gr/emcs/v1.03/tms">0001-01-01</DateOfPreparation>
<TimeOfPreparation xmlns="http://www.icisnet.gr/emcs/v1.03/tms">00:00:00.0000000+02:00</TimeOfPreparation>
</Header>
<Body>
<DeclarationOfExciseTaxesRegistration>
<SubmittingOperator />
<ExciseTaxesDeclaration>
<Fallbackflag>0</Fallbackflag>
<DocumentState>0</DocumentState>
<PaymentMethodCode>A</PaymentMethodCode>
<DeclarationTypeCode>30</DeclarationTypeCode>
<GeneralChemistryDetails />
<DeliveryDetails />
<ClearingAgent>
<ClearingAgentType>1</ClearingAgentType>
</ClearingAgent>
</ExciseTaxesDeclaration>
<ExciseTaxesDeclarationConsignor>
<ExciseTaxesDeclarationConsignorType>0</ExciseTaxesDeclarationConsignorType>
</ExciseTaxesDeclarationConsignor>
<ExciseTaxesObligee>
<ObligeeType>1</ObligeeType>
<ContactDetails />
</ExciseTaxesObligee>
<ExciseTaxesDeclarationConsignee>
<ConsigneeType>0</ConsigneeType>
<ConsigneeIdentificationType>1</ConsigneeIdentificationType>
<ContactDetails />
<SpecialConsignee>
<SpecialConsigneeLicenseType>1</SpecialConsigneeLicenseType>
</SpecialConsignee>
<VesselRegistrationDetails>
<VesselRegistrationType>1</VesselRegistrationType>
</VesselRegistrationDetails>
</ExciseTaxesDeclarationConsignee>
</DeclarationOfExciseTaxesRegistration>
</Body>
}
If someone can help me or need more of the code please tell me. Thans in advance.