首頁 > php教程 > php手册 > xml全国城市导入数据库

xml全国城市导入数据库

WBOY
發布: 2016-06-06 19:36:56
原創
1139 人瀏覽過

xml全国城市导入数据库 无 $string = XML?xml version="1.0" encoding="UTF-8"?!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"plist version="1.0"arraystring北京市/stringstring天津市/stringstri

xml全国城市导入数据库
$string = <<<XML
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<string>北京市</string>
	<string>天津市</string>
	<string>上海市</string>
	<string>重庆市</string>
	<string>合川市</string>
	<string>永川市</string>
	<string>江津市</string>
	<string>南川市</string>
	<string>石家庄市</string>
	<string>辛集市</string>
	<string>藁城市</string>
	<string>晋州市</string>
	<string>新乐市</string>
	<string>鹿泉市</string>
	<string>张家口市</string>
	<string>承德市</string>
	<string>秦皇岛市</string>
	<string>唐山市</string>
	<string>遵化市</string>
	<string>迁安市</string>
	<string>廊坊市</string>
	<string>霸州市</string>
	<string>三河市</string>
	<string>保定市</string>
	<string>定州市</string>
	<string>涿州市</string>
	<string>安国市</string>
	<string>高碑店市</string>
	<string>衡水市</string>
	<string>冀州市</string>
	<string>深州市</string>
	<string>河间市</string>
	<string>黄骅市</string>
	<string>任丘市</string>
	<string>泊头市</string>
	<string>沧州市</string>
	<string>沙河市</string>
	<string>南宫市</string>
	<string>邢台市</string>
	<string>武安市</string>
	<string>邯郸市</string>
	<string>古交市</string>
	<string>太原市</string>
	<string>朔州市</string>
	<string>大同市</string>
	<string>阳泉市</string>
	<string>潞城市</string>
	<string>长治市</string>
	<string>高平市</string>
	<string>晋城市</string>
	<string>原平市</string>
	<string>忻州市</string>
	<string>介休市</string>
	<string>晋中市</string>
	<string>霍州市</string>
	<string>侯马市</string>
	<string>临汾市</string>
	<string>汾阳市</string>
	<string>孝义市</string>
	<string>吕梁市</string>
	<string>河津市</string>
	<string>永济市</string>
	<string>运城市</string>
	<string>呼和浩特市</string>
	<string>包头市</string>
	<string>乌海市</string>
	<string>霍林郭勒市</string>
	<string>通辽市</string>
	<string>额尔古纳市</string>
	<string>根河市</string>
	<string>牙克石市</string>
	<string>扎兰屯市</string>
	<string>满洲里市</string>
	<string>呼伦贝尔市</string>
	<string>鄂尔多斯市</string>
	<string>丰镇市</string>
	<string>乌兰察布市</string>
	<string>巴彦淖尔市</string>
	<string>阿尔山市</string>
	<string>乌兰浩特市</string>
	<string>二连浩特市</string>
	<string>锡林浩特市</string>
	<string>新民市</string>
	<string>沈阳市</string>
	<string>凌源市</string>
	<string>北票市 </string>
	<string>朝阳市</string>
	<string>阜新市</string>
	<string>开原市</string>
	<string>调兵山市</string>
	<string>铁岭市</string>
	<string>抚顺市</string>
	<string>本溪市</string>
	<string>灯塔市</string>
	<string>辽阳市</string>
	<string>海城市</string>
	<string>鞍山市</string>
	<string>东港市</string>
	<string>凤城市</string>
	<string>丹东市</string>
	<string>庄河市</string>
	<string>普兰店市</string>
	<string>瓦房店市</string>
	<string>大连市</string>
	<string>盖州市</string>
	<string>大石桥市</string>
	<string>营口市</string>
	<string>盘锦市</string>
	<string>北宁市</string>
	<string>凌海市</string>
	<string>锦州市</string>
	<string>兴城市</string>
	<string>葫芦岛市</string>
	<string>榆树市</string>
	<string>九台市</string>
	<string>德惠市</string>
	<string>长春市</string>
	<string>洮南市</string>
	<string>大安市</string>
	<string>白城市</string>
	<string>松原市</string>
	<string>舒兰市</string>
	<string>桦甸市</string>
	<string>蛟河市</string>
	<string>磐石市</string>
	<string>吉林市</string>
	<string>公主岭市</string>
	<string>双辽市</string>
	<string>四平市</string>
	<string>辽源市</string>
	<string>集安市</string>
	<string>梅河口市</string>
	<string>通化市</string>
	<string>临江市</string>
	<string>白山市</string>
	<string>和龙市</string>
	<string>龙井市</string>
	<string>珲春市</string>
	<string>敦化市</string>
	<string>图们市</string>
	<string>延吉市</string>
	<string>阿城市</string>
	<string>五常市</string>
	<string>尚志市</string>
	<string>双城市</string>
	<string>哈尔滨市</string>
	<string>七台河市</string>
	<string>讷河市</string>
	<string>齐齐哈尔市</string>
	<string>五大连池市</string>
	<string>北安市</string>
	<string>黑河市</string>
	<string>大庆市</string>
	<string>鹤岗市</string>
	<string>铁力市</string>
	<string>伊春市</string>
	<string>富锦市</string>
	<string>同江市 </string>
	<string>佳木斯市</string>
	<string>双鸭山市</string>
	<string>密山市</string>
	<string>虎林市</string>
	<string>鸡西市</string>
	<string>宁安市</string>
	<string>海林市 </string>
	<string>绥芬河市</string>
	<string>穆棱市</string>
	<string>牡丹江市</string>
	<string>海伦市</string>
	<string>肇东市</string>
	<string>安达市</string>
	<string>绥化市</string>
	<string>南京市</string>
	<string>新沂市</string>
	<string>邳州市</string>
	<string>徐州市</string>
	<string>连云港市</string>
	<string>宿迁市</string>
	<string>淮安市</string>
	<string>大丰市</string>
	<string>东台市</string>
	<string>盐城市</string>
	<string>高邮市</string>
	<string>江都市</string>
	<string>仪征市</string>
	<string>扬州市</string>
	<string>兴化市</string>
	<string>姜堰市</string>
	<string>泰兴市</string>
	<string>靖江市</string>
	<string>泰州市</string>
	<string>如皋市</string>
	<string>通州市</string>
	<string>启东市</string>
	<string>海门市</string>
	<string>南通市</string>
	<string>句容市</string>
	<string>丹阳市</string>
	<string>扬中市</string>
	<string>镇江市</string>
	<string>溧阳市</string>
	<string>金坛市</string>
	<string>常州市</string>
	<string>宜兴市</string>
	<string>江阴市</string>
	<string>无锡市</string>
	<string>张家港市</string>
	<string>常熟市</string>
	<string>太仓市</string>
	<string>昆山市</string>
	<string>吴江市</string>
	<string>苏州市</string>
	<string>建德市</string>
	<string>富阳市</string>
	<string>临安市</string>
	<string>杭州市</string>
	<string>湖州市</string>
	<string>桐乡市</string>
	<string>海宁市</string>
	<string>平湖市</string>
	<string>嘉兴市</string>
	<string>舟山市</string>
	<string>奉化市</string>
	<string>余姚市</string>
	<string>慈溪市</string>
	<string>宁波市</string>
	<string>嵊州市</string>
	<string>上虞市</string>
	<string>诸暨市</string>
	<string>绍兴市</string>
	<string>江山市</string>
	<string>衢州市</string>
	<string>东阳市</string>
	<string>义乌市</string>
	<string>永康市</string>
	<string>兰溪市</string>
	<string>金华市</string>
	<string>温岭市</string>
	<string>临海市</string>
	<string>台州市</string>
	<string>乐清市</string>
	<string>瑞安市</string>
	<string>温州市</string>
	<string>龙泉市</string>
	<string>丽水市</string>
	<string>合肥市</string>
	<string>宿州市</string>
	<string>淮北市</string>
	<string>亳州市</string>
	<string>界首市</string>
	<string>阜阳市</string>
	<string>蚌埠市</string>
	<string>淮南市</string>
	<string>天长市</string>
	<string>明光市</string>
	<string>滁州市</string>
	<string>马鞍山市</string>
	<string>芜湖市</string>
	<string>铜陵市</string>
	<string>桐城市</string>
	<string>安庆市</string>
	<string>黄山市</string>
	<string>六安市</string>
	<string>巢湖市</string>
	<string>池州市</string>
	<string>宁国市</string>
	<string>宣城市</string>
	<string>长乐市</string>
	<string>福清市</string>
	<string>福州市</string>
	<string>建阳市</string>
	<string>建瓯市</string>
	<string>武夷山市</string>
	<string>邵武市</string>
	<string>南平市</string>
	<string>莆田市</string>
	<string>永安市</string>
	<string>三明市</string>
	<string>南安市</string>
	<string>晋江市</string>
	<string>石狮市</string>
	<string>泉州市</string>
	<string>厦门市</string>
	<string>龙海市</string>
	<string>漳州市</string>
	<string>漳平市</string>
	<string>龙岩市</string>
	<string>福鼎市</string>
	<string>福安市</string>
	<string>宁德市</string>
	<string>南昌市</string>
	<string>瑞昌市</string>
	<string>九江市</string>
	<string>乐平市</string>
	<string>景德镇市</string>
	<string>贵溪市</string>
	<string>鹰潭市</string>
	<string>新余市</string>
	<string>萍乡市</string>
	<string>南康市</string>
	<string>瑞金市</string>
	<string>赣州市</string>
	<string>德兴市</string>
	<string>上饶市</string>
	<string>抚州市</string>
	<string>高安市</string>
	<string>樟树市</string>
	<string>丰城市</string>
	<string>宜春市</string>
	<string>吉安市</string>
	<string>章丘市</string>
	<string>济南市</string>
	<string>临清市</string>
	<string>聊城市</string>
	<string>禹城市</string>
	<string>乐陵市</string>
	<string>德州市</string>
	<string>东营市</string>
	<string>淄博市</string>
	<string>寿光市</string>
	<string>诸城市</string>
	<string>青州市</string>
	<string>高密市</string>
	<string>昌邑市 </string>
	<string>安丘市</string>
	<string>潍坊市</string>
	<string>招远市</string>
	<string>蓬莱市</string>
	<string>莱州市</string>
	<string>莱阳市</string>
	<string>龙口市</string>
	<string>海阳市</string>
	<string>栖霞市</string>
	<string>烟台市</string>
	<string>文登市</string>
	<string>乳山市</string>
	<string>荣成市</string>
	<string>威海市</string>
	<string>莱西市</string>
	<string>胶南市</string>
	<string>平度市</string>
	<string>即墨市</string>
	<string>胶州市</string>
	<string>青岛市</string>
	<string>日照市</string>
	<string>临沂市</string>
	<string>滕州市</string>
	<string>枣庄市</string>
	<string>邹城市</string>
	<string>兖州市</string>
	<string>曲阜市</string>
	<string>济宁市</string>
	<string>肥城市</string>
	<string>新泰市</string>
	<string>泰安市</string>
	<string>莱芜市</string>
	<string>滨州市</string>
	<string>菏泽市</string>
	<string>济源市</string>
	<string>荥阳市</string>
	<string>巩义市</string>
	<string>新密市</string>
	<string>登封市</string>
	<string>新郑市</string>
	<string>郑州市</string>
	<string>灵宝市</string>
	<string>义马市</string>
	<string>三门峡市</string>
	<string>偃师市</string>
	<string>洛阳市</string>
	<string>沁阳市</string>
	<string>孟州市</string>
	<string>焦作市</string>
	<string>辉县市</string>
	<string>卫辉市</string>
	<string>新乡市</string>
	<string>鹤壁市</string>
	<string>林州市</string>
	<string>安阳市</string>
	<string>濮阳市</string>
	<string>开封市</string>
	<string>永城市</string>
	<string>商丘市</string>
	<string>长葛市</string>
	<string>禹州市</string>
	<string>许昌市</string>
	<string>漯河市</string>
	<string>汝州市</string>
	<string>舞钢市</string>
	<string>平顶山市</string>
	<string>邓州市</string>
	<string>南阳市</string>
	<string>信阳市</string>
	<string>项城市</string>
	<string>周口市</string>
	<string>驻马店市</string>
	<string>潜江市</string>
	<string>天门市</string>
	<string>仙桃市</string>
	<string>武汉市</string>
	<string>丹江口市</string>
	<string>十堰市</string>
	<string>宜城市</string>
	<string>枣阳市</string>
	<string>老河口市 </string>
	<string>襄樊市</string>
	<string>钟祥市</string>
	<string>荆门市</string>
	<string>汉川市</string>
	<string>安陆市</string>
	<string>应城市</string>
	<string>黄冈市</string>
	<string>鄂州市</string>
	<string>大冶市</string>
	<string>黄石市</string>
	<string>赤壁市</string>
	<string>咸宁市</string>
	<string>松滋市</string>
	<string>洪湖市</string>
	<string>石首市</string>
	<string>荆州市</string>
	<string>当阳市</string>
	<string>宜都市</string>
	<string>枝江市</string>
	<string>宜昌市</string>
	<string>广水市</string>
	<string>随州市</string>
	<string>利川市</string>
	<string>恩施市</string>
	<string>浏阳市</string>
	<string>长沙市</string>
	<string>张家界市</string>
	<string>津市市</string>
	<string>常德市</string>
	<string>沅江市</string>
	<string>益阳市</string>
	<string>临湘市</string>
	<string>汨罗市</string>
	<string>岳阳市</string>
	<string>醴陵市</string>
	<string>株洲市</string>
	<string>韶山市</string>
	<string>湘乡市</string>
	<string>湘潭市</string>
	<string>耒阳市</string>
	<string>常宁市</string>
	<string>衡阳市</string>
	<string>资兴市</string>
	<string>郴州市</string>
	<string>永州市</string>
	<string>武冈市</string>
	<string>邵阳市</string>
	<string>洪江市</string>
	<string>怀化市</string>
	<string>涟源市</string>
	<string>冷水江市</string>
	<string>娄底市</string>
	<string>吉首市</string>
	<string>从化市</string>
	<string>增城市 </string>
	<string>广州市</string>
	<string>连州市</string>
	<string>英德市</string>
	<string>清远市</string>
	<string>南雄市</string>
	<string>乐昌市</string>
	<string>韶关市</string>
	<string>河源市</string>
	<string>兴宁市</string>
	<string>梅州市</string>
	<string>潮州市</string>
	<string>汕头市</string>
	<string>普宁市</string>
	<string>揭阳市</string>
	<string>陆丰市</string>
	<string>汕尾市</string>
	<string>惠州市</string>
	<string>东莞市</string>
	<string>深圳市</string>
	<string>珠海市</string>
	<string>中山市</string>
	<string>鹤山市</string>
	<string>开平市</string>
	<string>台山市</string>
	<string>恩平市</string>
	<string>江门市</string>
	<string>佛山市</string>
	<string>四会市</string>
	<string>高要市</string>
	<string>肇庆市</string>
	<string>罗定市</string>
	<string>云浮市</string>
	<string>阳春市</string>
	<string>阳江市</string>
	<string>高州市</string>
	<string>信宜市</string>
	<string>化州市</string>
	<string>茂名市</string>
	<string>廉江市</string>
	<string>雷州市</string>
	<string>吴川市</string>
	<string>湛江市</string>
	<string>南宁市</string>
	<string>桂林市</string>
	<string>柳州市</string>
	<string>岑溪市</string>
	<string>梧州市</string>
	<string>桂平市</string>
	<string>贵港市</string>
	<string>北流市</string>
	<string>玉林市</string>
	<string>钦州市</string>
	<string>北海市</string>
	<string>东兴市</string>
	<string>防城港市</string>
	<string>凭祥市</string>
	<string>崇左市</string>
	<string>百色市</string>
	<string>宜州市</string>
	<string>河池市</string>
	<string>合山市</string>
	<string>来宾市</string>
	<string>贺州市</string>
	<string>儋州市</string>
	<string>东方市</string>
	<string>五指山市</string>
	<string>万宁市</string>
	<string>琼海市</string>
	<string>文昌市</string>
	<string>海口市</string>
	<string>三亚市</string>
	<string>崇州市</string>
	<string>邛崃市 </string>
	<string>彭州市</string>
	<string>都江堰市</string>
	<string>成都市</string>
	<string>广元市</string>
	<string>江油市</string>
	<string>绵阳市</string>
	<string>绵竹市</string>
	<string>广汉市</string>
	<string>什邡市</string>
	<string>德阳市</string>
	<string>阆中市</string>
	<string>南充市</string>
	<string>华蓥市</string>
	<string>广安市</string>
	<string>遂宁市</string>
	<string>内江市</string>
	<string>峨眉山市</string>
	<string>乐山市</string>
	<string>自贡市</string>
	<string>泸州市</string>
	<string>宜宾市</string>
	<string>攀枝花市</string>
	<string>巴中市</string>
	<string>万源市</string>
	<string>达州市</string>
	<string>简阳市</string>
	<string>资阳市</string>
	<string>眉山市</string>
	<string>雅安市</string>
	<string>西昌市</string>
	<string>清镇市</string>
	<string>贵阳市</string>
	<string>六盘水市</string>
	<string>仁怀市</string>
	<string>赤水市</string>
	<string>遵义市</string>
	<string>毕节市</string>
	<string>铜仁市</string>
	<string>凯里市</string>
	<string>福泉市</string>
	<string>都匀市</string>
	<string>兴义市</string>
	<string>安宁市</string>
	<string>昆明市</string>
	<string>宣威市</string>
	<string>曲靖市</string>
	<string>玉溪市</string>
	<string>保山市</string>
	<string>昭通市</string>
	<string>丽江市</string>
	<string>思茅市</string>
	<string>临沧市</string>
	<string>瑞丽市</string>
	<string>潞西市</string>
	<string>大理市</string>
	<string>楚雄市</string>
	<string>开远市</string>
	<string>个旧市</string>
	<string>景洪市</string>
	<string>拉萨市</string>
	<string>日喀则市</string>
	<string>西安市</string>
	<string>延安市</string>
	<string>铜川市</string>
	<string>韩城市</string>
	<string>华阴市</string>
	<string>渭南市</string>
	<string>兴平市</string>
	<string>咸阳市</string>
	<string>宝鸡市</string>
	<string>汉中市</string>
	<string>榆林市</string>
	<string>安康市</string>
	<string>商洛市</string>
	<string>兰州市</string>
	<string>嘉峪关市</string>
	<string>金昌市</string>
	<string>白银市</string>
	<string>天水市</string>
	<string>武威市</string>
	<string>敦煌市</string>
	<string>玉门市 </string>
	<string>酒泉市</string>
	<string>张掖市</string>
	<string>庆阳市</string>
	<string>平凉市</string>
	<string>定西市</string>
	<string>陇南市</string>
	<string>临夏市</string>
	<string>合作市</string>
	<string>西宁市</string>
	<string>德令哈市格尔木市</string>
	<string>灵武市</string>
	<string>银川市</string>
	<string>石嘴山市</string>
	<string>青铜峡市</string>
	<string>吴忠市</string>
	<string>固原市</string>
	<string>中卫市</string>
	<string>五家渠市</string>
	<string>图木舒克市</string>
	<string>阿拉尔市</string>
	<string>石河子市</string>
	<string>乌鲁木齐市</string>
	<string>克拉玛依市</string>
	<string>喀什市</string>
	<string>阿克苏市</string>
	<string>和田市</string>
	<string>吐鲁番市</string>
	<string>哈密市</string>
	<string>阿图什市</string>
	<string>博乐市</string>
	<string>米泉市</string>
	<string>阜康市</string>
	<string>昌吉市</string>
	<string>库尔勒市</string>
	<string>奎屯市</string>
	<string>伊宁市</string>
	<string>乌苏市</string>
	<string>塔城市</string>
	<string>阿勒泰市</string>
	<string>香港市</string>
	<string>澳门市</string>
	<string>高雄市</string>
	<string>台北市</string>
	<string>嘉义市</string>
	<string>新竹市</string>
	<string>台南市</string>
	<string>台中市</string>
	<string>基隆市</string>
</array>
</plist>

XML;

$xml = simplexml_load_string($string);
// print_r($xml);
$login = $xml->array;//这里返回的依然是个SimpleXMLElement对象
///print_r($login);
// $login = (string) $xml->array;//在做数据比较时,注意要先强制转换
// print_r($login);
function objectToArray($e){  // 对象转换成数组
    $e=(array)$e;
    foreach($e as $k=>$v){
        if( gettype($v)=='resource' ) return;
        if( gettype($v)=='object' || gettype($v)=='array' )
            $e[$k]=(array)objectToArray($v);
    }
    return $e;
}
$arr=objectToArray($login);
//  print_r($arr['string']);
	foreach($arr['string'] as $val){
		mysql_query("insert into p_city(`name`)values('$val')");		
	}
	$s=mysql_errno();
	echo "{\"s\":$s}";	
登入後複製
相關標籤:
來源:php.cn
本網站聲明
本文內容由網友自願投稿,版權歸原作者所有。本站不承擔相應的法律責任。如發現涉嫌抄襲或侵權的內容,請聯絡admin@php.cn
熱門推薦
熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板