function import_xml($content) { $xml = FrmProAppHelper::xml2ary($content); $to_import = array(); foreach ($xml['formidable'] as $xmls) { foreach ($xmls as $type => $xml_content) { $to_import[$type] = array(); foreach ($xmls[$type]['_c'] as $xml_vars) { if (!isset($xml_vars[0])) { $xml_vars[] = $xml_vars; } foreach ($xml_vars as $xml_var) { $new_item = array(); foreach ($xml_var['_c'] as $var_key => $var) { if (isset($var['_v'])) { $new_item[$var_key] = $var['_v']; } else { $new_item[$var_key] = array(); if ($var_key == 'fields' or $var_key == 'item_meta') { foreach ($var['_c'] as $v) { foreach ($v as $v1) { if (isset($v1['_c'])) { $new_join = array(); foreach ($v1['_c'] as $v_key => $v2) { if (isset($v2['_v'])) { $new_join[$v_key] = $v2['_v']; } else { $new_join[$v_key] = FrmProAppHelper::xml_array_to_frm($v2); } } $new_item[$var_key][] = $new_join; } } } } else { $new_item[$var_key] = FrmProAppHelper::xml_array_to_frm($var, $new_item[$var_key]); } } } $to_import[$type][] = $new_item; } } } } //now add $to_import to the db foreach ($to_import as $import_type => $datas) { foreach ($datas as $data) { echo '<h1>' . $import_type . '</h1>'; if ($import_type == 'forms') { //echo '<br/><br/>FORM: '; print_r($data); //FrmForm::create( $data ); //now add fields foreach ($data['fields'] as $field_data) { //echo '<br/><br/>FIELD: '; print_r($field_data); //FrmFields::create( $field_data, false ); } } else { if ($import_type == 'items') { //echo '<br/><br/>ENTRY: '; print_r($data); //FrmEntry::create( $data ); } else { if ($import_type == 'displays') { //echo '<br/><br/>DISPLAY: '; print_r($data); //FrmProDisplay::create( $data ); } } } } } }