I develop an application where I create an XML document from a class which I serialize, the problem occurs when a certain node must be repeated more than once, I explain the document that I am creating is an invoice if I sell an article the node appears an Once, if I sell two items the node will appear twice and so on.
How can I create this node as many times as the number of products my invoice has?
The code I use to add the node is the following, how can I modify it so that it repeats as many times as necessary?
DetalleServicio = new FacturaElectronicaLineaDetalle[]
{
new FacturaElectronicaLineaDetalle
{
NumeroLinea = numeroLinea,
Codigo = new CodigoType[]
{
new CodigoType
{
Tipo=(CodigoTypeTipo)Enum.Parse(typeof(CodigoTypeTipo), tipo),
Codigo= codigo
}
},
Cantidad = cantidad,
UnidadMedida=(UnidadMedidaType)Enum.Parse(typeof(UnidadMedidaType), unidadMedida),
UnidadMedidaComercial=unidadComercial,
Detalle= detalle,
PrecioUnitario=precio,
MontoTotal=precio * cantidad,
MontoDescuento=montoDescuento,
NaturalezaDescuento= naturalezaDescuento,
SubTotal= subTotal,
MontoTotalLinea= precio * cantidad - montoDescuento
}
}