Weedpacket, I have one question and I am hoping that you can help me.
I am running a modified version of the above code to try to determine the maximum size of the text stored at each XML "line" to create the MySQL database, however I am finding some problems.
The code is basically the same, the part I modified was this:
function startElement($parser, $name, $attrs) {
global $tag_name;
$tag_name = $name;
// Output the element name
echo ucfirst(strtolower($name)), ': ';
}
// Closing element handler function
function endElement($parser, $name) {
// Output a new line
echo "<br>";
}
// Character data handler function
function characterData($parser, $value) {
global $SizeOfFields;
// Output the character data (text)
if (strlen($value) > strlen($SizeOfFields[$tag_name]))
{
$SizeOfFields[$tag_inicial] = strlen($value);
}
echo $value;
}
Where $SizeOfFields is an empty array ($tag_name simply stores the current XML tag name so that I can identify to which value does $value come from at the characterData function) where I plan to store all the maximum sizes so that finally I can print it out with print_r($SizeOfFields);
However I am getting weird results:
[LICITACION] => 2
[NUMERO] => 13
[MODIFICADA] => 2
[PRECIOBASES] => 2
[ESTADO] => 2
[DEPENDENCIA] => 23
[ACEPTAELECTRONICA] => 2
[CARACTER] => 2
[PUBLICACION] => 2
[TIPO] => 13
[LIMITEBASES] => 2
[JUNTA] => 2
[APERTURATECNICA] => 2
[APERTURAECONOMICA] => 2
[VISITA] => 106
[AREACONSULTA] => 68
[DOMICILIO] => 116
[DIASVENTA] => 15
[HORARIOVENTA] => 33
[TELEFONO] => 14
[FAX] => 14
[FORMADEPAGO] => 2
[LUGARENTREGA] => 155
[DIASENTREGA] => 15
[HORARIOENTREGA] => 36
[PLAZOENTREGA] => 35
[NOMBRE] => 3
[DOMICILIOUNIDAD] => 113
[PRESUPUESTOMINIMO] => 4
[PRESUPUESTOMAXIMO] => 2
[DETALLEPARTIDA] => 4
[NUMEROPARTIDA] => 4
[CABMS] => 4
[DESCRIPCION] => 4
[CANTIDAD] => 4
[UNIDAD] => 4
[ESPECIFICACIONTECNICA] => 4
[NOMBREPROVEEDOR] => 4
[FECHACOMPRA] => 2
[LIGA] => 4
[DOCTO] => 2
[LICITACIONES] => 1
[UNIDADCOMPRADORA] => 3
[PARTIDAS] => 3
[DOCUMENTOS] => 3
[ARCHIVO] => 4
[FORMAPAGO] => 46
[PROVEEDORES] => 2
[PROVEEDOR] => 4
[REQUISITOS] => 973
[EXPERIENCIATECNICA] => 105
[CRITERIOSADJUDICACION] => 465
[CAPITALCONTABLE] => 11
[UBICACION] => 4
[FECHAINICIO] => 4
[PLAZOEJECUCION] => 4
[CLAVE] => 4
[ESPECIFICACION] => 2
Some of those numbers make sense, but many of them are way too small... as you can see from my first post, <EspecificacionTecnica> is much bigger than the 4 characters that this array is storing... I am not sure if this is a logical or another kind of problem.
If I cant get this to work I guess I will just make 255 big all of the fields (expect for those clearly bigger than that, where I would use text) and then make some SQL query to find out the real sizes and correct the fields.
I guess this is more a really proud question since I cant believe my reasoning is that wrong so that I cant get the correct numbers to be stored :p...
anyway, thanks for your help.