|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2009-04-28 06:36 UTC] bbarnett at gt dot co dot cr
Description:
------------
I'm receiving and errors when I try to read and XML string, previously generated by my code.
Reproduce code:
---------------
$doc = new DOMDocument('1.0'); $doc->formatOutput = true;
$root = $doc->createElement('X_A_PagoGen'); $root = $doc->appendChild($root);
$title = $doc->createElement('Banco'); $title = $root->appendChild($title); $text = $doc->createTextNode(trim($codigobanco)); $text = $title->appendChild($text);
$title = $doc->createElement('Localizacion'); $title = $root->appendChild($title); $text = $doc->createTextNode(trim($localizacion)); $text = $title->appendChild($text);
$title = $doc->createElement('NotaCredito'); $title = $root->appendChild($title); $text = $doc->createTextNode(llenacampo(trim($remesa),12,'0','derecha')); $text = $title->appendChild($text);
$title = $doc->createElement('Correlativo'); $title = $root->appendChild($title); $text = $doc->createTextNode(trim($factura)); $text = $title->appendChild($text);
$title = $doc->createElement('Self'); $title = $root->appendChild($title); $text = $doc->createTextNode(trim($self)); $text = $title->appendChild($text);
$title = $doc->createElement('Monto'); $title = $root->appendChild($title); $text = $doc->createTextNode(llenacampo(trim($monto),10,'0','derecha')); $text = $title->appendChild($text);
$title = $doc->createElement('Agencia'); $title = $root->appendChild($title); $text = $doc->createTextNode(trim($recaudadorCNFL)); $text = $title->appendChild($text);
$title = $doc->createElement('FechaPago'); $title = $root->appendChild($title); $text = $doc->createTextNode(trim(fecha1())); $text = $title->appendChild($text);
$title = $doc->createElement('FechaCaja'); $title = $root->appendChild($title); $text = $doc->createTextNode(trim($deposito)); $text = $title->appendChild($text);
$tramaxml=$doc->saveXML();
$xml2= simplexml_load_string(trim($tramaxml));
Expected result:
----------------
XML Object
Actual result:
--------------
Error:
Fatal Error 73: Couldn't find end of Start Tag Fech line 10 Line: 10 Column: 8
Fatal Error 77: Premature end of data in tag X_A_PagoGen line 2 Line: 10 Column: 8
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 13:00:02 2025 UTC |
This is the function that I use to complete the length of the string function llenacampo($valor,$tamano,$llenado,$justificado){ // Esta funcion devuelve el valor basado en los parametros para ser agregado en la trama $devuelve=''; if ($justificado=='derecha'){ //Llena el campo de derecha a izquierda $cuanto=$tamano-strlen(trim($valor)); for ($i=0;$i<$cuanto;$i++){ $devuelve.=$llenado; } $devuelve.=$valor; } elseif ($justificado=='izquierda'){ //Llena el campo de derecha a izquierda $devuelve.=$valor; $cuanto=$tamano-strlen(trim($valor)); for ($i=0;$i<$cuanto;$i++){ $devuelve.=$llenado; } } return $devuelve; }