Unicode C
Unicode C
Insert Signed XML as Base64 Data into Invoice XML
See more TicketBAI Examples
Demonstrates how to insert previously signed XML into another XML as base64 data.Chilkat Unicode C Downloads
#include <C_CkStringBuilderW.h>
#include <C_CkXmlW.h>
void ChilkatSample(void)
{
BOOL success;
HCkStringBuilderW sb1;
HCkStringBuilderW sb2;
HCkXmlW xml;
success = FALSE;
// We wish to create the following XML:
// <?xml version="1.0" encoding="UTF-8" standalone="no"?><lrpficfcsgap:LROEPF140IngresosConFacturaConSGAltaPeticion xmlns:lrpficfcsgap="https://www.batuz.eus/fitxategiak/batuz/LROE/esquemas/LROE_PF_140_1_1_Ingresos_ConfacturaConSG_AltaPeticion_V1_0_2.xsd">
// <Cabecera>
// <Modelo>140</Modelo>
// <Capitulo>1</Capitulo>
// <Subcapitulo>1.1</Subcapitulo>
// <Operacion>A00</Operacion>
// <Version>1.0</Version>
// <Ejercicio>2022</Ejercicio>
// <ObligadoTributario>
// <NIF>79732487C</NIF>
// <ApellidosNombreRazonSocial>ARRIOLA LEJARDI ANE</ApellidosNombreRazonSocial>
// </ObligadoTributario>
// </Cabecera>
// <Ingresos>
// <Ingreso>
// <TicketBai>PD94bWw...ldEJhaT4=</TicketBai>
// <Renta>
// <DetalleRenta>
// <Epigrafe>197330</Epigrafe>
// </DetalleRenta>
// </Renta>
// </Ingreso>
// <Ingreso>
// <TicketBai>PD94bWw...rZXRCYWk+</TicketBai>
// <Renta>
// <DetalleRenta>
// <Epigrafe>197330</Epigrafe>
// <IngresoAComputarIRPFDiferenteBaseImpoIVA>S</IngresoAComputarIRPFDiferenteBaseImpoIVA>
// <ImporteIngresoIRPF>400.00</ImporteIngresoIRPF>
// </DetalleRenta>
// </Renta>
// </Ingreso>
// </Ingresos>
// </lrpficfcsgap:LROEPF140IngresosConFacturaConSGAltaPeticion>
// Use this online tool to generate code from sample XML:
// Generate Code to Create XML
// First get the signed XML created in these other examples
// TicketBAI Sign XML Example 1
sb1 = CkStringBuilderW_Create();
success = CkStringBuilderW_LoadFile(sb1,L"qa_output/signedXml_1.xml",L"utf-8");
// TicketBAI Sign XML Example 2
sb2 = CkStringBuilderW_Create();
success = CkStringBuilderW_LoadFile(sb2,L"qa_output/signedXml_2.xml",L"utf-8");
xml = CkXmlW_Create();
CkXmlW_putTag(xml,L"lrpficfcsgap:LROEPF140IngresosConFacturaConSGAltaPeticion");
CkXmlW_AddAttribute(xml,L"xmlns:lrpficfcsgap",L"https://www.batuz.eus/fitxategiak/batuz/LROE/esquemas/LROE_PF_140_1_1_Ingresos_ConfacturaConSG_AltaPeticion_V1_0_2.xsd");
CkXmlW_UpdateChildContent(xml,L"Cabecera|Modelo",L"140");
CkXmlW_UpdateChildContent(xml,L"Cabecera|Capitulo",L"1");
CkXmlW_UpdateChildContent(xml,L"Cabecera|Subcapitulo",L"1.1");
CkXmlW_UpdateChildContent(xml,L"Cabecera|Operacion",L"A00");
CkXmlW_UpdateChildContent(xml,L"Cabecera|Version",L"1.0");
CkXmlW_UpdateChildContent(xml,L"Cabecera|Ejercicio",L"2022");
CkXmlW_UpdateChildContent(xml,L"Cabecera|ObligadoTributario|NIF",L"79732487C");
CkXmlW_UpdateChildContent(xml,L"Cabecera|ObligadoTributario|ApellidosNombreRazonSocial",L"ARRIOLA LEJARDI ANE");
CkXmlW_UpdateChildContent(xml,L"Ingresos|Ingreso|TicketBai",CkStringBuilderW_getEncoded(sb1,L"base64",L"utf-8"));
CkXmlW_UpdateChildContent(xml,L"Ingresos|Ingreso|Renta|DetalleRenta|Epigrafe",L"197330");
CkXmlW_UpdateChildContent(xml,L"Ingresos|Ingreso[1]|TicketBai",CkStringBuilderW_getEncoded(sb2,L"base64",L"utf-8"));
CkXmlW_UpdateChildContent(xml,L"Ingresos|Ingreso[1]|Renta|DetalleRenta|Epigrafe",L"197330");
CkXmlW_UpdateChildContent(xml,L"Ingresos|Ingreso[1]|Renta|DetalleRenta|IngresoAComputarIRPFDiferenteBaseImpoIVA",L"S");
CkXmlW_UpdateChildContent(xml,L"Ingresos|Ingreso[1]|Renta|DetalleRenta|ImporteIngresoIRPF",L"400.00");
wprintf(L"%s\n",CkXmlW_getXml(xml));
success = CkXmlW_SaveXml(xml,L"qa_output/ticketBAI_invoice.xml");
CkStringBuilderW_Dispose(sb1);
CkStringBuilderW_Dispose(sb2);
CkXmlW_Dispose(xml);
}