Buenas a todos/as
Tengo el siguiente código para crear un XML.
El caso es que en lugar de valores FIJOS, deseo pasar los valores de las variables para construir el mismo, pero en realidad no se. He intentado todo.
ejemplo, $tipopago = $xml->createElement('tipopago','1988');
pero es su lugar debe de ir DesctipoPago y así en los demás
Gracias
function crear(){
$Notarjeta='45993430058328675';
$Fechacaducidad='1018';
$Codigocvc2='x36';
$Tipomoneda='978';
$Totalimporte='1.00';
$Nocomercio='4345729730';
$Noterminal='2';
$DesctipoPago='PAGO';
$Notimestamp=date("Ymd His");
$codigoclave='3331953';
$finalcadena = "$tipoPago$tarjeta$caducidad$importe$moneda$comerc io$terminal$timestamp$clave";
$Lafirma = sha1($finalcadena);
$xml = new DomDocument('1.0', 'UTF-8');
$operaciones = $xml->createElement('operaciones');
$operaciones = $xml->appendChild($operaciones);
$operacion = $xml->createElement('operacion');
$operacion = $operaciones->appendChild($operacion);
$datosPago = $xml->createElement('datosPago');
$datosPago = $operacion->appendChild($datosPago);
$datosPagoTarjeta = $xml->createElement('datosPagoTarjeta');
$datosPagoTarjeta = $datosPago->appendChild($datosPagoTarjeta);
$tarjeta = $xml->createElement('tarjeta','Notarjeta');
$tarjeta = $datosPagoTarjeta->appendChild($tarjeta);
$caducidad = $xml->createElement('caducidad','El Alquimista');
$caducidad = $datosPagoTarjeta->appendChild($caducidad);
$cvc2 = $xml->createElement('cvc2','1988');
$cvc2 = $datosPagoTarjeta->appendChild($cvc2);
$datosCompra = $xml->createElement('datosCompra');
$datosCompra= $operacion->appendChild($datosCompra);
$moneda = $xml->createElement('moneda','Paulo Coelho');
$moneda = $datosCompra->appendChild($moneda);
$importe = $xml->createElement('importe','El Alquimista');
$importe = $datosCompra->appendChild($importe);
$comercio = $xml->createElement('comercio','1988');
$comercio = $datosCompra->appendChild($comercio);
$terminal = $xml->createElement('terminal','1988');
$terminal = $datosCompra->appendChild($terminal);
$tipopago = $xml->createElement('tipopago','1988');
$tipopago = $datosCompra->appendChild($tipopago);
$timestamp = $xml->createElement('timestamp','45121');
$timestamp = $operacion->appendChild($timestamp);
$firma = $xml->createElement('firma','AAABBB');
$firma = $operacion->appendChild($firma);
$xml->formatOutput = true;
$el_xml = $xml->saveXML();
$xml->save('operaciones.xml');
}