Ver Mensaje Individual
  #3 (permalink)  
Antiguo 28/02/2007, 10:44
Avatar de locojars
locojars
 
Fecha de Ingreso: mayo-2002
Mensajes: 265
Antigüedad: 22 años
Puntos: 4
Re: Manipulación de archivos csv o xml

Busca en el Tío Google, el te puede dar una buena ayuda. En todo caso si deseas manipular XML aqui tienes una pequeña idea:

http://php5.bitflux.org/xmloncrack/slide_51.php

Si quieres leer un CSV, aqui te dejo un pequeño script que te ayudará con eso:

Código PHP:
// open the text file
$fd fopen ("empleados.csv""r");
echo 
"<table border=1>";
// initialize a loop to go through each line of the file
while (!feof ($fd)) {
    
// declare an array to hold all of the contents of each row, indexed
    
$buffer fgetcsv($fd4096);
    
// start a row for the table
    
echo "<tr>\n";
    
// this for loop is the meat, the 17 represents the number of columns in the text file, hey...the world is a hack!
    // when this is re-created with MySQL use the mysql_num_fileds() function to get this number
    
for ($i 0$i 4; ++$i){
        
// if the field is empty, make it = '&nbsp' so NN doesn't puke on an empty
        
echo "<td>";
        if (
$buffer[$i] == ""){
            
$buffer[$i] = "&nbsp;";
            }
        
// if its the email field, construct a mailto link
        
if ($i == 5    && $buffer[$i] !="&nbsp;" && $buffer[$i] !="email" ){
            
$buffer[$i] = "<a href=\"mailto:$buffer[$i]\">$buffer[$i]</a>";
            }
        
// print <td>'s with each index
            
echo "<td class=\"list\">$buffer[$i]</td>\n";
    }
    echo 
"</tr>\n";
    }
    
    echo 
"</table>";
    
fclose ($fd); 
Espero te sirva.

Salu2,
Jars
__________________
No le digas a Jehová que tan grande es tu problema, dile a tu problema cuan grande es Jehová.