Import XML with attributes into mysql

前端 未结 3 1870
梦谈多话
梦谈多话 2020-12-17 06:56

I have a large (~30Mb) XML file like this:




        
3条回答
  •  有刺的猬
    2020-12-17 07:53

    I try to answer my question.

    xpath("/LIC/Item") as $docs)
      {
            foreach($docs->Field as $field) 
            {
                $resultstr[] = $field["Name"];
            }
        $sql_head = headquote($resultstr);
        $sql_ins = "INSERT INTO table_name (";
        $sql_dec = ") VALUE (";
        unset($resultstr);
        $fresult = (array)$docs;
        $fvalue = array_pop($fresult);
        $sql_val = numking($fvalue);
        $sql_end = ");";
        $query_to_use_for_mysql = ($sql_ins.$sql_head.$sql_dec.$sql_val.$sql_end);
    
        unset($fresult);
        unset($fvalue);
     }
     ?>
    

    And add this two functions:

    
    

    Thanks to all for help!

提交回复
热议问题