Rust
Rust
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 Rust Downloads
// 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
let sb1 = chilkat::StringBuilder::new();
let _ = sb1.load_file("qa_output/signedXml_1.xml", "utf-8").is_ok();
// TicketBAI Sign XML Example 2
let sb2 = chilkat::StringBuilder::new();
let _ = sb2.load_file("qa_output/signedXml_2.xml", "utf-8").is_ok();
let xml = chilkat::Xml::new();
xml.set_tag("lrpficfcsgap:LROEPF140IngresosConFacturaConSGAltaPeticion");
let _ = xml.add_attribute("xmlns:lrpficfcsgap", "https://www.batuz.eus/fitxategiak/batuz/LROE/esquemas/LROE_PF_140_1_1_Ingresos_ConfacturaConSG_AltaPeticion_V1_0_2.xsd");
xml.update_child_content("Cabecera|Modelo", "140");
xml.update_child_content("Cabecera|Capitulo", "1");
xml.update_child_content("Cabecera|Subcapitulo", "1.1");
xml.update_child_content("Cabecera|Operacion", "A00");
xml.update_child_content("Cabecera|Version", "1.0");
xml.update_child_content("Cabecera|Ejercicio", "2022");
xml.update_child_content("Cabecera|ObligadoTributario|NIF", "79732487C");
xml.update_child_content("Cabecera|ObligadoTributario|ApellidosNombreRazonSocial", "ARRIOLA LEJARDI ANE");
xml.update_child_content("Ingresos|Ingreso|TicketBai", &sb1.get_encoded("base64", "utf-8").unwrap_or_default());
xml.update_child_content("Ingresos|Ingreso|Renta|DetalleRenta|Epigrafe", "197330");
xml.update_child_content("Ingresos|Ingreso[1]|TicketBai", &sb2.get_encoded("base64", "utf-8").unwrap_or_default());
xml.update_child_content("Ingresos|Ingreso[1]|Renta|DetalleRenta|Epigrafe", "197330");
xml.update_child_content("Ingresos|Ingreso[1]|Renta|DetalleRenta|IngresoAComputarIRPFDiferenteBaseImpoIVA", "S");
xml.update_child_content("Ingresos|Ingreso[1]|Renta|DetalleRenta|ImporteIngresoIRPF", "400.00");
println!("{}", xml.get_xml().unwrap_or_default());
let _ = xml.save_xml("qa_output/ticketBAI_invoice.xml").is_ok();