I am sending a XML to a aspnet core web api. The value for the namespace prefix cfdi:
is defined in a containing node:
<cfdi:Comprobante>
<cfdi:Conceptos>
</cfdi:Conceptos>
<cfdi:Addenda>
<bfa2:AddendaBuzonFiscal version="2.0" xmlns:bfa2="http://www.buzonfiscal.com/ns/addenda/bf/2"><bfa2:TipoDocumento nombreCorto="FAC" descripcion="Factura"/><bfa2:CFD totalConLetra="CINCUENTA Y DOS MIL QUINIENTOS OCHENTA Y NUEVE PESOS 64/100 M.N." observaciones="OBSERVACIONES"/><bfa2:Extra atributo="ClaveTransportista" valor="00328"/><bfa2:Extra atributo="NoRelacionPemex" valor="1-2"/>
<bfa2:Extra atributo="NoConvenio" valor="5"/>
</bfa2:AddendaBuzonFiscal>
<Encabezado NumOrden="" NumFacturaOriginal="" FechaDePedido=""/>
<Envio Calle="" NoExterior="" Colonia="" Localidad="" Municipio="" Estado="" Pais="" CodigoPostal="" NombreEnviar=""/><Detalle OrdenCompraLinea="10" GRNumber="GRN"/><Detalle OrdenCompraLinea="10" GRNumber="GRN"/><Detalle OrdenCompraLinea="10" GRNumber="GRN"/>
</cfdi:Addenda>
</cfdi:Comprobante>
To deserialize this I made the class Comprobante
:
public class Comprobante : IValidatableObject
{
[Required]
[XmlArray("Conceptos"), XmlArrayItem(typeof(Concepto), ElementName = "Concepto")]
public List<Concepto> Conceptos { get; set; }
public Addenda Addenda { get; set; }
}
Everything is mapped to the class properties but the Addenda
node could receive anything -- any number of valid XML nodes -- so I don´t have a class definition. I.e. the Addenda
node could contain n nodes that I don’t know about, the information is validated in the recipient end. For example a customer could ask to add a node with a PO number, another could ask for buyer name. Etc.
If I need to get all the Addenda
node content as string, how should I declare it in the class?