php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #48096 Error reading XML string
Submitted: 2009-04-28 06:36 UTC Modified: 2009-05-09 01:00 UTC
From: bbarnett at gt dot co dot cr Assigned:
Status: No Feedback Package: DOM XML related
PHP Version: 5.2.9 OS: Windows 2003 Server R2
Private report: No CVE-ID: None
View Add Comment Developer Edit
Anyone can comment on a bug. Have a simpler test case? Does it work for you on a different platform? Let us know!
Just going to say 'Me too!'? Don't clutter the database with that please — but make sure to vote on the bug!
Your email address:
MUST BE VALID
Solve the problem:
39 + 32 = ?
Subscribe to this entry?

 
 [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

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2009-04-28 06:44 UTC] bbarnett at gt dot co dot cr
This is an example of the XML string:
<?xml version="1.0"?>
<X_A_PagoGen>
  <Banco>2</Banco>
  <Localizacion>2603460081</Localizacion>
  <NotaCredito>000000009787</NotaCredito>
  <Correlativo>82108608</Correlativo>
  <Self>9</Self>
  <Monto>0000003930</Monto>
  <Agencia>1400</Agencia>
  <FechaPago>20090427</FechaPago>
  <FechaCaja>20090428</FechaCaja>
</X_A_PagoGen>
 [2009-04-28 11:57 UTC] rrichards@php.net
Thank you for this bug report. To properly diagnose the problem, we
need a short but complete example script to be able to reproduce
this bug ourselves. 

A proper reproducing script starts with <?php and ends with ?>,
is max. 10-20 lines long and does not require any external 
resources such as databases, etc. If the script requires a 
database to demonstrate the issue, please make sure it creates 
all necessary tables, stored procedures etc.

Please avoid embedding huge scripts into the report.

Included script does not run because you are using functions and 
variables that are not included here. As I said before this is an 
encoding issue and I would bet it due to the values of them.




 [2009-04-29 16:22 UTC] bbarnett at gt dot co dot cr
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;
}
 [2009-05-01 13:58 UTC] rrichards@php.net
You are still missing all the values being populated as well as another 
function.
 [2009-05-09 01:00 UTC] php-bugs at lists dot php dot net
No feedback was provided for this bug for over a week, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Mar 28 15:01:29 2024 UTC