here the excel sheet contains two coulmns
1.url
2.result
parsed the above are saved into corresponding variables,$url,$result
enter data into a excel sheet then save it as excel xml with extension .xml
upload in to the script
if ( $_FILES['file']['tmp_name'] )
{
$dom = DOMDocument::load( $_FILES['file']['tmp_name'] );
$rows = $dom->getElementsByTagName( 'Row' );
$first_row = true;
foreach ($rows as $row)
{
if ( !$first_row )
{
$url = "";
$result = "";
$index = 1;
$cells = $row->getElementsByTagName( 'Cell' );
// echo $cells;
foreach( $cells as $cell )
{
$ind = $cell->getAttribute( 'Index' );
if ( $ind != null ) $index = $ind;
//echo $index;
if ( $index == 1 ) $url = $cell->nodeValue;
if ( $index == 2 ) $result = $cell->nodeValue;
//echo "$cell->nodeValue";
$index += 1;
}
I use this same script.
ReplyDelete$ind = $cell->getAttribute( 'Index' );
The Index is actually
ss:Index
At least that is what it shows in my excel xml file and what works for me. The reason for that is the cells are skipped and the only indication is that the next cell has the index (indicating the skipped index).