700字范文,内容丰富有趣,生活中的好帮手!
700字范文 > php读取xml文件 并存入数据库

php读取xml文件 并存入数据库

时间:2019-03-12 05:13:57

相关推荐

php读取xml文件 并存入数据库

附:xml文件

<beans>

<bean>

<yearMonth>12</yearMonth>

<odpType>ODP1</odpType>

<batchNo>1206000001</batchNo>

<salesDate>-12-06</salesDate>

<tvbCreateDate>-12-06 11:02:11</tvbCreateDate>

<dealerCode>A09594</dealerCode>

<dealerName>吴江富骏</dealerName>

<ownerId>888888</ownerId>

<vin>LVSHMFAC6GH108124</vin>

<vinClear>正确</vinClear>

<vinUpdate></vinUpdate>

<color>玛瑙黑</color>

<series>金牛座</series>

<model>金牛座 2.0AT</model>

<catCode>88F55</catCode>

<licenseNo>沪F00001</licenseNo>

<ownerName>王</ownerName>

<ownerNameClear>更新</ownerNameClear>

<ownerNameUpdate>王1</ownerNameUpdate>

<gender>男</gender>

<genderClear>正确</genderClear>

<genderUpdate></genderUpdate>

<certificateType>居民身份证</certificateType>

<certificateCode>510321198312126575</certificateCode>

<certificateCodeClear>正确</certificateCodeClear>

<certificateCodeUpdate></certificateCodeUpdate>

<birthday>1990-01-02</birthday>

<marriage>已婚</marriage>

<phone>021-33882222</phone>

<phoneClear>正确</phoneClear>

<phoneUpdate>021-33882222</phoneUpdate>

<mobile>15502152629</mobile>

<mobileClear>正确</mobileClear>

<mobileUpdate>15502152629</mobileUpdate>

<province>上海</province>

<provinceClear>正确</provinceClear>

<provinceUpdate></provinceUpdate>

<city>上海</city>

<cityClear>正确</cityClear>

<cityUpdate></cityUpdate>

<district>浦东新区</district>

<districtClear>正确</districtClear>

<districtUpdate>浦东新区</districtUpdate>

<address>兰城路108弄14号304室</address>

<addressClear>正确</addressClear>

<addressUpdate>兰城路108弄14号304室</addressUpdate>

<zipCode>210000</zipCode>

<zipCodeClear>正确</zipCodeClear>

<zipCodeUpdate></zipCodeUpdate>

<contactName>王立君</contactName>

<contactNameClear>正确</contactNameClear>

<contactNameUpdate></contactNameUpdate>

<contactGender>男</contactGender>

<contactGenderClear>正确</contactGenderClear>

<contactGenderUpdate></contactGenderUpdate>

<contactPhone>021-39274298</contactPhone>

<contactPhoneClear>正确</contactPhoneClear>

<contactPhoneUpdate></contactPhoneUpdate>

<contactMobile>15502152629</contactMobile>

<contactMobileClear>正确</contactMobileClear>

<contactMobileUpdate></contactMobileUpdate>

<contactEmail>scwanglijun@</contactEmail>

<contactEmailClear>正确</contactEmailClear>

<contactEmailUpdate></contactEmailUpdate>

<contactAddress>上海市浦东新区兰城路108弄14号304室</contactAddress>

<contactAddressClear>正确</contactAddressClear>

<contactAddressUpdate></contactAddressUpdate>

<carSync>1</carSync>

<carEA>1</carEA>

<fordPass>1</fordPass>

<subCCNumber>1</subCCNumber>

<obType>owner</obType>

<priority>A</priority>

<dupType>K12</dupType>

<obStatus>2</obStatus>

<obDate>-12-10 11:02:11</obDate>

<contactObStatus>2</contactObStatus>

<ownerObStatus>2</ownerObStatus>

<obCount>3</obCount>

<agentNo>22222</agentNo>

<lastObPhoneType>phone</lastObPhoneType>

<obDetails>

<calling>

<obNo>1</obNo>

<calling>-12-10 11:02:11</calling>

<obStatus>2</obStatus>

<obPhoneType>phone</obPhoneType>

<obTelNo>15502152629</obTelNo>

<recording>http://www.xqing.info/com/xxx.mp3</recording>

</calling>

<calling>

<obNo>1</obNo>

<calling>-12-10 11:02:11</calling>

<obStatus>2</obStatus>

<obPhoneType>mobile</obPhoneType>

<obTelNo>15502152629</obTelNo>

<recording>http://www.xqing.info/com/xxx.mp3</recording>

</calling>

</obDetails>

<carUseFolk>1111</carUseFolk>

<referColor>玛瑙黑</referColor>

<whetherColor>是</whetherColor>

<whetherCompany>是</whetherCompany>

<companyName>长安礼物</companyName>

<companyNameClear>正确</companyNameClear>

<companyNameUpdate></companyNameUpdate>

<remark>备用字段</remark>

<questions>

<questionNo>0007</questionNo>

<questionName>1</questionName>

<questionType>1</questionType>

<answer>wwww</answer>

</questions>

</bean>

<bean>

<yearMonth>12</yearMonth>

<odpType>ODP1</odpType>

<batchNo>1206000001</batchNo>

<salesDate>-12-06</salesDate>

<tvbCreateDate>-12-06 11:02:11</tvbCreateDate>

<dealerCode>A09594</dealerCode>

<dealerName>吴江富骏</dealerName>

<ownerId>888888</ownerId>

<vin>LVSHMFAC6GH108124</vin>

<vinClear>正确</vinClear>

<vinUpdate></vinUpdate>

<color>玛瑙黑</color>

<series>金牛座</series>

<model>金牛座 2.0AT</model>

<catCode>88F55</catCode>

<licenseNo>沪F00001</licenseNo>

<ownerName>王</ownerName>

<ownerNameClear>更新</ownerNameClear>

<ownerNameUpdate>王</ownerNameUpdate>

<gender>男</gender>

<genderClear>正确</genderClear>

<genderUpdate></genderUpdate>

<certificateType>居民身份证</certificateType>

<certificateCode>510321198312126575</certificateCode>

<certificateCodeClear>正确</certificateCodeClear>

<certificateCodeUpdate></certificateCodeUpdate>

<birthday>1990-01-02</birthday>

<marriage>已婚</marriage>

<phone>021-33882222</phone>

<phoneClear>正确</phoneClear>

<phoneUpdate>021-33882222</phoneUpdate>

<mobile>15502152629</mobile>

<mobileClear>正确</mobileClear>

<mobileUpdate>15502152629</mobileUpdate>

<province>上海</province>

<provinceClear>正确</provinceClear>

<provinceUpdate></provinceUpdate>

<city>上海</city>

<cityClear>正确</cityClear>

<cityUpdate></cityUpdate>

<district>浦东新区</district>

<districtClear>正确</districtClear>

<districtUpdate>浦东新区</districtUpdate>

<address>兰城路108弄14号304室</address>

<addressClear>正确</addressClear>

<addressUpdate>兰城路108弄14号304室</addressUpdate>

<zipCode>210000</zipCode>

<zipCodeClear>正确</zipCodeClear>

<zipCodeUpdate></zipCodeUpdate>

<email>scwangliju@</email>

<emailClear>正确</emailClear>

<emailUpdate></emailUpdate>

<contactName>王立君</contactName>

<contactNameClear>正确</contactNameClear>

<contactNameUpdate></contactNameUpdate>

<contactGender>男</contactGender>

<contactGenderClear>正确</contactGenderClear>

<contactGenderUpdate></contactGenderUpdate>

<contactPhone>021-39274298</contactPhone>

<contactPhoneClear>正确</contactPhoneClear>

<contactPhoneUpdate></contactPhoneUpdate>

<contactMobile>15502152629</contactMobile>

<contactMobileClear>正确</contactMobileClear>

<contactMobileUpdate></contactMobileUpdate>

<contactEmail>scwanglijun@</contactEmail>

<contactEmailClear>正确</contactEmailClear>

<contactEmailUpdate></contactEmailUpdate>

<contactAddress>上海市浦东新区兰城路108弄14号304室</contactAddress>

<contactAddressClear>正确</contactAddressClear>

<contactAddressUpdate></contactAddressUpdate>

<carSync>1</carSync>

<carEA>1</carEA>

<fordPass>1</fordPass>

<subCCNumber>1</subCCNumber>

<obType>owner</obType>

<priority>A</priority>

<dupType>K12</dupType>

<obStatus>2</obStatus>

<obDate>-12-10 11:02:11</obDate>

<contactObStatus>2</contactObStatus>

<ownerObStatus>2</ownerObStatus>

<obCount>3</obCount>

<agentNo>22222</agentNo>

<lastObPhoneType>phone</lastObPhoneType>

<obDetails>

<calling>

<obNo>1</obNo>

<calling>-12-10 11:02:11</calling>

<obStatus>2</obStatus>

<obPhoneType>phone</obPhoneType>

<obTelNo>15502152629</obTelNo>

<recording>http://www.xqing.info/com/xxx.mp3</recording>

</calling>

<calling>

<obNo>1</obNo>

<calling>-12-10 11:02:11</calling>

<obStatus>2</obStatus>

<obPhoneType>mobile</obPhoneType>

<obTelNo>15502152629</obTelNo>

<recording>http://www.xqing.info/com/xxx.mp3</recording>

</calling>

</obDetails>

<carUseFolk>1111</carUseFolk>

<referColor>玛瑙黑</referColor>

<whetherColor>是</whetherColor>

<whetherCompany>是</whetherCompany>

<companyName>长安礼物</companyName>

<companyNameClear>正确</companyNameClear>

<companyNameUpdate></companyNameUpdate>

<remark>备用字段</remark>

<questions>

<questionNo>0007</questionNo>

<questionName>1</questionName>

<questionType>1</questionType>

<answer>wwww</answer>

</questions>

</bean>

</beans>

php程序:

/*******读取xml文件***********/

$doc = new DOMDocument();

$doc->load(dirname(__FILE__).'/1212SEND.xml'); //读取xml文件

$bean = $doc->getElementsByTagName( 'bean' ); //取得bean标签的对象数组

$infoArr = array( 'yearMonth' => 'yearMonth','odpType' => 'odpType','salesDate' => 'salesDate',

'tvbCreateDate' => 'tvbCreateDate','dealerCode' => 'dealerCode','dealerName' => 'dealerName',

'ownerId' => 'ownerId','vin' => 'vin','color' => 'color',

'series' => 'series','model' => 'model','catCode' => 'catCode',

'licenseNo' => 'licenseNo','ownerName' => 'ownerName','gender' => 'gender',

'certificateType' => 'certificateType','certificateCode' => 'certificateCode','birthday' => 'birthday',

'marriage' => 'marriage','phone' => 'phone','mobile' => 'mobile',

'province' => 'province','city' => 'city','district' => 'district',

'address' => 'address','zipCode' => 'zipCode','email' => 'email',

'contactName' => 'contactName','contactGender' => 'contactGender','contactPhone' => 'contactPhone',

'contactMobile' => 'contactMobile','contactEmail' => 'contactEmail','contactAddress' => 'contactAddress',

'carSync' => 'carSync','carEA' => 'carEA','fordPass' => 'fordPass',

'subCCNumber' => 'subCCNumber','obType' => 'obType','priority' => 'priority',

'dupType' => 'dupType','remark' => 'remark','sendDate' => 'sendDate');

foreach( $bean as $key )

{

foreach ($infoArr as $k => $v) {

$$v = $key->getElementsByTagName($k)->item(0)->nodeValue; //取得node中的值

$data .= $$v.'|';

}

$group_id = 218;

$task_id = 395;

$info = array(

'group_id' => $group_id,

'task_id' => $task_id,

'is_lock' => - 1,

'create_time' => gmtime() ,

'create_no' => local_date("YmdHis") ,

'create_user_account' => $_SESSION['user_info']['user_account'],

'create_user_name' => $_SESSION['user_info']['user_name'],

);

$info['phone_num'] = $mobile;

$info['quota_keywords'] = '';

$info['ext_info'] = substr($data,0,-1);

$db->autoExecute($GLOBALS['sc']->table('item_phone_res') , $info, 'INSERT', '', 'SILENT');

unset($data);

}

rename(dirname(__FILE__).'/1212SEND.xml', dirname(__FILE__).'/1212SEND_yidu.xml');

/******************/

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。