PHP DOMDocument output HTML page code -
i've made web application in user inputs data , xml generated values ms sql server database, since users going using locally being hosted on server, need trigger downloads instead of saving location, , while that, output includes html in page, code
if(isset($_post['enviar'])) { $dia = $_post['dia']; $mes = $_post['mes']; $anio = $_post['anio']; $fechao = $dia.'/'.$mes.'/'.$anio; $rifr = 'j'.$_post['rifr']; $cod = $_post['cod']; $xml = new domdocument('1.0', 'iso-8859-1'); $sql = "select replace(replace(replace(dbo.saprov.id3, '-', ''), '.', ''), ' ', '') rif, right(replace(replace(replace(saacxp_1.numerod, '-', ''), 'a', ''), ' ', ''), 8) n_factura, right(replace(replace(saacxp_1.nroctrol, '-', ''), ' ', ''), 8) nroctrol, '0' + dbo.sapagcxp.codrete codoper, dbo.sapagcxp.basereten monto, isnull(dbo.saoper.clase, '2') porcentaje, substring(convert(varchar, dbo.saacxp.fechae, 112), 1, 6) mes dbo.saoper right outer join dbo.saacxp saacxp_1 right outer join dbo.sapagcxp right outer join dbo.saprov inner join dbo.saacxp on dbo.saprov.codprov = dbo.saacxp.codprov on dbo.sapagcxp.numerod = dbo.saacxp.numerod on saacxp_1.nrounico = dbo.saacxp.nroregi on dbo.saoper.codoper = dbo.saacxp.codoper (dbo.saacxp.tipocxp = '21')"; $stmt = sqlsrv_query($conex, $sql) or die('query failed!'); while($row = sqlsrv_fetch_array($stmt, sqlsrv_fetch_assoc)) { $root = $xml->createelement("relacionretencionesislr"); $xml->appendchild($root); $root->setattribute("rifagente", $row['rif']); $root->appendchild($xml->createattribute('periodo'))->appendchild($xml->createtextnode($row['mes'])); // $a1 = $xml->createelement("rifretenido"); $rif = $xml->createtextnode($rifr); $a1->appendchild($rif); // $a2 = $xml->createelement("numerofactura"); $nfactura = $xml->createtextnode($row['n_factura']); $a2->appendchild($nfactura); // $a3 = $xml->createelement("numerocontrol"); $ncontrol = $xml->createtextnode($row['nroctrol']); $a3->appendchild($ncontrol); // $a4 = $xml->createelement("fechaoperacion"); $fecha = $xml->createtextnode($fechao); $a4->appendchild($fecha); // $a5 = $xml->createelement("codigoconcepto"); $concepto = $xml->createtextnode($cod); $a5->appendchild($concepto); // $a6 = $xml->createelement("montooperacion"); $monto = $xml->createtextnode($row['monto']); $a6->appendchild($monto); // $a7 = $xml->createelement("porcentajeretencion"); $porcentaje = $xml->createtextnode($row['porcentaje']); $a7->appendchild($porcentaje); // $book = $xml->createelement("detalleretencion"); $book->appendchild($a1); $book->appendchild($a2); $book->appendchild($a3); $book->appendchild($a4); $book->appendchild($a5); $book->appendchild($a6); $book->appendchild($a7); $root->appendchild($book); } $xml->formatoutput = true; $name = strftime('backup_%m_%d_%y.xml'); header('content-disposition: attachment;filename=' . $name); header('content-type: text/xml'); $xml->save('php://output'); // echo $xml->savexml(); // $xml->save("mybooks.xml") or die("error"); }
i've searched on google can find people want output html code xml
you can not output 2 responses single http request.
much image or download need separate request outputs xml , provide user way call (link, form, redirect, javascript).
Comments
Post a Comment