`
huaye2007
  • 浏览: 38634 次
  • 性别: Icon_minigender_1
  • 来自: 武汉
文章分类
社区版块
存档分类
最新评论

dom4j解析XML文件

 
阅读更多
XML文件数据:
<root>
    <country id="China" name="中国" en="China">
        <area id="Main" name="直辖市" en="Main">
            <city id="101010100" name="北京" en="Beijing" />
            <city id="101020100" name="上海" en="Shanghai" />
            <city id="101030100" name="天津" en="Tianjin" />
            <city id="101040100" name="重庆" en="Chongqing" />
        </area>
        <area id="S.A.R." name="特别行政区" en="S.A.R.">
            <city id="101320101" name="香港" en="Hong Kong" />
            <city id="101330101" name="澳门" en="Macau" />
        </area>
        <area id="Hebei" name="河北省" en="Hebei">
            <city id="101090101" name="石家庄" en="Shijiazhuang" />
            <city id="101090401" name="承德" en="Chengde" />
            <city id="101090301" name="张家口" en="Zhangjiakou" />
            <city id="101091101" name="秦皇岛" en="Qinhuangdao" />
            <city id="101090501" name="唐山" en="Tangshan" />
            <city id="101090601" name="廊坊" en="Langfang" />
            <city id="101090201" name="保定" en="Baoding" />
            <city id="101090701" name="沧州" en="Cangzhou" />
            <city id="101090801" name="衡水" en="Hengshui" />
            <city id="101090901" name="邢台" en="Xingtai" />
            <city id="101091001" name="邯郸" en="Handan" />
        </area>
        <area id="Shanxi" name="山西省" en="Shanxi">
            <city id="101100101" name="太原" en="Taiyuan" />
            <city id="101100201" name="大同" en="Datong" />
            <city id="101100301" name="阳泉" en="Yangquan" />
            <city id="101100501" name="长治" en="Changzhi" />
            <city id="101100601" name="晋城" en="Jincheng" />
            <city id="101100901" name="朔州" en="Shuozhou" />
            <city id="101100401" name="晋中" en="Jinzhong" />
            <city id="101100801" name="运城" en="Yuncheng" />
            <city id="101101001" name="忻州" en="Xinzhou" />
            <city id="101100701" name="临汾" en="Linfen" />
            <city id="101101100" name="吕梁" en="Lvliang" />
            <city id="101101101" name="离石" en="Lishi" />
            <city id="101100402" name="榆次" en="Yuci" />
        </area>
        <area id="Inner Mongolia" name="内蒙古" en="Inner Mongolia">
            <city id="101080101" name="呼和浩特" en="Huhehaote" />
            <city id="101080201" name="包头" en="Baotou" />
            <city id="101081000" name="呼伦贝尔" en="Hulunbeier" />
            <city id="101081101" name="乌兰浩特" en="Wulanhaote" />
            <city id="101080501" name="通辽" en="Tongliao" />
            <city id="101080601" name="赤峰" en="Chifeng" />
            <city id="101080901" name="锡林浩特" en="Xilinhaote" />
            <city id="101080401" name="集宁" en="Jining" />
            <city id="101080701" name="鄂尔多斯" en="Eerduosi" />
            <city id="101080801" name="临河" en="Linhe" />
            <city id="101080301" name="乌海" en="Wuhai" />
            <city id="101081201" name="阿拉善左旗" en="Alashanzuoqi" />
        </area>
        <area id="Liaoning" name="辽宁省" en="Liaoning">
            <city id="101070101" name="沈阳" en="Shenyang" />
            <city id="101070201" name="大连" en="Dalian" />
            <city id="101070301" name="鞍山" en="Anshan" />
            <city id="101070401" name="抚顺" en="Fushun" />
            <city id="101070501" name="本溪" en="Benxi" />
            <city id="101070601" name="丹东" en="Dandong" />
            <city id="101070701" name="锦州" en="Jinzhou" />
            <city id="101070801" name="营口" en="Yingkou" />
            <city id="101070901" name="阜新" en="Fuxin" />
            <city id="101071001" name="辽阳" en="Liaoyang" />
            <city id="101071101" name="铁岭" en="Tieling" />
            <city id="101071201" name="朝阳" en="Chaoyang" />
            <city id="101071301" name="盘锦" en="Panjin" />
            <city id="101071401" name="葫芦岛" en="Huludao" />
        </area>
        <area id="Jilin" name="吉林省" en="Jilin">
            <city id="101060101" name="长春" en="Changchun" />
            <city id="101060201" name="吉林" en="Jilin" />
            <city id="101060401" name="四平" en="Siping" />
            <city id="101060701" name="辽源" en="Liaoyuan" />
            <city id="101060501" name="通化" en="Tonghua" />
            <city id="101060901" name="白山" en="Baishan" />
            <city id="101060801" name="松原" en="Songyuan" />
            <city id="101060601" name="白城" en="Baicheng" />
            <city id="101060301" name="延吉" en="Yanji" />
        </area>
        <area id="Heilongjiang" name="黑龙江省" en="Heilongjiang">
            <city id="101050101" name="哈尔滨" en="Haerbin" />
            <city id="101050201" name="齐齐哈尔" en="Qiqihaer" />
            <city id="101050301" name="牡丹江" en="Mudanjiang" />
            <city id="101050401" name="佳木斯" en="Jiamusi" />
            <city id="101050901" name="大庆" en="Daqing" />
            <city id="101051101" name="鸡西" en="Jixi" />
            <city id="101051301" name="双鸭山" en="Shuangyashan" />
            <city id="101050801" name="伊春" en="Yichun" />
            <city id="101051002" name="七台河" en="Qitaihe" />
            <city id="101051201" name="鹤岗" en="Hegang" />
            <city id="101050601" name="黑河" en="Heihe" />
            <city id="101050501" name="绥化" en="Suihua" />
            <city id="101050701" name="大兴安岭" en="Daxinganling" />
        </area>
        <area id="Jiangsu" name="江苏省" en="Jiangsu">
            <city id="101190101" name="南京" en="Nanjing" />
            <city id="101190201" name="无锡" en="Wuxi" />
            <city id="101190801" name="徐州" en="Xuzhou" />
            <city id="101191101" name="常州" en="Changzhou" />
            <city id="101190401" name="苏州" en="Suzhou" />
            <city id="101190501" name="南通" en="Nantong" />
            <city id="101191001" name="连云港" en="Lianyungang" />
            <city id="101190901" name="淮安" en="Huaian" />
            <city id="101190701" name="盐城" en="Yancheng" />
            <city id="101190601" name="扬州" en="Yangzhou" />
            <city id="101190301" name="镇江" en="Zhenjiang" />
            <city id="101191201" name="泰州" en="Taizhou" />
            <city id="101191301" name="宿迁" en="Suqian" />
            <city id="101190403" name="张家港" en="Zhangjiagang" />
        </area>
        <area id="Zhejiang" name="浙江省" en="Zhejiang">
            <city id="101210101" name="杭州" en="Hangzhou" />
            <city id="101210401" name="宁波" en="Ningbo" />
            <city id="101210701" name="温州" en="Wenzhou" />
            <city id="101210301" name="嘉兴" en="Jiaxing" />
            <city id="101210201" name="湖州" en="Huzhou" />
            <city id="101210501" name="绍兴" en="Shaoxing" />
            <city id="101210503" name="上虞" en="Shangyu" />
            <city id="101210901" name="金华" en="Jinhua" />
            <city id="101210904" name="义乌" en="Yiwu" />
            <city id="101211001" name="衢州" en="Quzhou" />
            <city id="101211101" name="舟山" en="Zhoushan" />
            <city id="101210601" name="台州" en="Taizhou" />
            <city id="101210801" name="丽水" en="Lishui" />
            <city id="101210802" name="遂昌" en="Suichang" />
            <city id="101210403" name="慈溪" en="Cixi" />
            <city id="101210103" name="桐庐" en="Tonglu" />
            <city id="101210607" name="温岭" en="Wenling" />
        </area>
        <area id="Anhui" name="安徽省" en="Anhui">
            <city id="101220101" name="合肥" en="Hefei" />
            <city id="101220901" name="亳州" en="Bozhou" />
            <city id="101221201" name="淮北" en="Huaibei" />
            <city id="101220701" name="宿州" en="Suzhou" />
            <city id="101220801" name="阜阳" en="Fuyang" />
            <city id="101220201" name="蚌埠" en="Bengbu" />
            <city id="101220401" name="淮南" en="Huainan" />
            <city id="101221101" name="滁州" en="Chuzhou" />
            <city id="101221501" name="六安" en="Luan" />
            <city id="101221601" name="巢湖" en="Chaohu" />
            <city id="101220301" name="芜湖" en="Wuhu" />
            <city id="101220501" name="马鞍山" en="Maanshan" />
            <city id="101220601" name="安庆" en="Anqing" />
            <city id="101221701" name="池州" en="Chizhou" />
            <city id="101221301" name="铜陵" en="Tongling" />
            <city id="101221401" name="宣城" en="Xuancheng" />
            <city id="101221001" name="黄山" en="Huangshan" />
            <city id="101221008" name="黄山景区" en="Huangshan Mt." />
        </area>
        <area id="Fujian" name="福建省" en="Fujian">
            <city id="101230101" name="福州" en="Fuzhou" />
            <city id="101230201" name="厦门" en="Xiamen" />
            <city id="101230401" name="莆田" en="Putian" />
            <city id="101230801" name="三明" en="Sanming" />
            <city id="101230501" name="泉州" en="Quanzhou" />
            <city id="101230601" name="漳州" en="Zhangzhou" />
            <city id="101230901" name="南平" en="Nanping" />
            <city id="101230905" name="武夷山" en="Wuyishan" />
            <city id="101230701" name="龙岩" en="Longyan" />
            <city id="101230301" name="宁德" en="Ningde" />
            <city id="101230308" name="福鼎" en="Fuding" />
        </area>
        <area id="Jiangxi" name="江西省" en="Jiangxi">
            <city id="101240101" name="南昌" en="Nanchang" />
            <city id="101240201" name="九江" en="Jiujiang" />
            <city id="101240801" name="景德镇" en="Jingdezhen" />
            <city id="101240901" name="萍乡" en="Pingxiang" />
            <city id="101241001" name="新余" en="Xinyu" />
            <city id="101241101" name="鹰潭" en="Yingtan" />
            <city id="101240701" name="赣州" en="Ganzhou" />
            <city id="101240501" name="宜春" en="Yichun" />
            <city id="101240301" name="上饶" en="Shangrao" />
            <city id="101240601" name="吉安" en="Jian" />
            <city id="101240608" name="井冈山" en="Jinggangshan" />
            <city id="101240401" name="抚州" en="Fuzhou" />
        </area>
        <area id="Shandong" name="山东省" en="Shandong">
            <city id="101120101" name="济南" en="Jinan" />
            <city id="101120201" name="青岛" en="Qingdao" />
            <city id="101120301" name="淄博" en="Zibo" />
            <city id="101121401" name="枣庄" en="Zaozhuang" />
            <city id="101121201" name="东营" en="Dongying" />
            <city id="101120501" name="烟台" en="Yantai" />
            <city id="101120601" name="潍坊" en="Weifang" />
            <city id="101120603" name="寿光" en="Shouguang" />
            <city id="101120609" name="诸城" en="Zhucheng" />
            <city id="101120701" name="济宁" en="Jining" />
            <city id="101120711" name="邹城" en="Zoucheng" />
            <city id="101120801" name="泰安" en="Taian" />
            <city id="101120802" name="新泰" en="Xintai" />
            <city id="101121301" name="威海" en="Weihai" />
            <city id="101121501" name="日照" en="Rizhao" />
            <city id="101121601" name="莱芜" en="Laiwu" />
            <city id="101120901" name="临沂" en="Linyi" />
            <city id="101120401" name="德州" en="Dezhou" />
            <city id="101121701" name="聊城" en="Liaocheng" />
            <city id="101121101" name="滨州" en="Binzhou" />
            <city id="101121001" name="菏泽" en="Heze" />
            <city id="101120106" name="济阳" en="Jiyang" />
            <city id="101120208" name="平度" en="Pingdu" />
        </area>
        <area id="Henan" name="河南省" en="Henan">
            <city id="101180101" name="郑州" en="Zhengzhou" />
            <city id="101180801" name="开封" en="Kaifeng" />
            <city id="101180901" name="洛阳" en="Luoyang" />
            <city id="101180502" name="平顶山" en="Pingdingshan" />
            <city id="101180201" name="安阳" en="Anyang" />
            <city id="101181101" name="焦作" en="Jiaozuo" />
            <city id="101181201" name="鹤壁" en="Hebi" />
            <city id="101180301" name="新乡" en="Xinxiang" />
            <city id="101181301" name="濮阳" en="Puyang" />
            <city id="101180401" name="许昌" en="Xuchang" />
            <city id="101181501" name="漯河" en="Luohe" />
            <city id="101181701" name="三门峡" en="Sanmenxia" />
            <city id="101180701" name="南阳" en="Nanyang" />
            <city id="101181001" name="商丘" en="Shangqiu" />
            <city id="101180601" name="信阳" en="Xinyang" />
            <city id="101181401" name="周口" en="Zhoukou" />
            <city id="101181601" name="驻马店" en="Zhumadian" />
            <city id="101181801" name="济源" en="Jiyuan" />
            <city id="101181009" name="永城" en="Yongcheng" />
        </area>
        <area id="Hubei" name="湖北省" en="Hubei">
            <city id="101200101" name="武汉" en="Wuhan" />
            <city id="101200601" name="黄石" en="Huangshi" />
            <city id="101200201" name="襄樊" en="Xiangfan" />
            <city id="101200801" name="荆州" en="Jingzhou" />
            <city id="101200901" name="宜昌" en="Yichang" />
            <city id="101200501" name="黄冈" en="Huanggang" />
            <city id="101200301" name="鄂州" en="Ezhou" />
            <city id="101201101" name="十堰" en="Shiyan" />
            <city id="101200401" name="孝感" en="Xiaogan" />
            <city id="101201401" name="荆门" en="Jingmen" />
            <city id="101200701" name="咸宁" en="Xianning" />
            <city id="101201301" name="随州" en="Suizhou" />
            <city id="101201001" name="恩施" en="Enshi" />
            <city id="101201501" name="天门" en="Tianmen" />
            <city id="101201601" name="仙桃" en="Xiantao" />
            <city id="101200405" name="应城" en="Yingcheng" />
        </area>
        <area id="Hunan" name="湖南省" en="Hunan">
            <city id="101250101" name="长沙" en="Changsha" />
            <city id="101250301" name="株洲" en="Zhuzhou" />
            <city id="101250201" name="湘潭" en="Xiangtan" />
            <city id="101250401" name="衡阳" en="Hengyang" />
            <city id="101250409" name="南岳" en="Nanyue" />
            <city id="101250901" name="邵阳" en="Shaoyang" />
            <city id="101251001" name="岳阳" en="Yueyang" />
            <city id="101250601" name="常德" en="Changde" />
            <city id="101251101" name="张家界" en="Zhangjiajie" />
            <city id="101250700" name="益阳" en="Yiyang" />
            <city id="101250501" name="郴州" en="Chenzhou" />
            <city id="101251401" name="永州" en="Yongzhou" />
            <city id="101251201" name="怀化" en="Huaihua" />
            <city id="101250801" name="娄底" en="Loudi" />
            <city id="101251501" name="吉首" en="Jishou" />
            <city id="101251301" name="黔阳" en="Qianyang" />
        </area>
        <area id="Guangdong" name="广东省" en="Guangdong">
            <city id="101280101" name="广州" en="Guangzhou" />
            <city id="101280601" name="深圳" en="Shenzhen" />
            <city id="101280701" name="珠海" en="Zhuhai" />
            <city id="101280501" name="汕头" en="Shantou" />
            <city id="101280800" name="佛山" en="Foshan" />
            <city id="101280201" name="韶关" en="Shaoguan" />
            <city id="101281201" name="河源" en="Heyuan" />
            <city id="101280401" name="梅州" en="Meizhou" />
            <city id="101280301" name="惠州" en="Huizhou" />
            <city id="101282101" name="汕尾" en="Shanwei" />
            <city id="101281601" name="东莞" en="Dongguan" />
            <city id="101281701" name="中山" en="Zhongshan" />
            <city id="101281101" name="江门" en="Jiangmen" />
            <city id="101281103" name="开平" en="Kaiping" />
            <city id="101281801" name="阳江" en="Yangjiang" />
            <city id="101281001" name="湛江" en="Zhangjiang" />
            <city id="101282001" name="茂名" en="Maoming" />
            <city id="101280901" name="肇庆" en="Zhaoqing" />
            <city id="101281301" name="清远" en="Qingyuan" />
            <city id="101281501" name="潮州" en="Chaozhou" />
            <city id="101281901" name="揭阳" en="Jieyang" />
            <city id="101281401" name="云浮" en="Yunfu" />
        </area>
        <area id="Guangxi" name="广西" en="Guangxi">
            <city id="101300101" name="南宁" en="Nanning" />
            <city id="101300301" name="柳州" en="Liuzhou" />
            <city id="101300501" name="桂林" en="Guilin" />
            <city id="101300601" name="梧州" en="Wuzhou" />
            <city id="101301301" name="北海" en="Beihai" />
            <city id="101301401" name="防城港" en="Fangchenggang" />
            <city id="101301101" name="钦州" en="Qinzhou" />
            <city id="101300801" name="贵港" en="Guigang" />
            <city id="101300901" name="玉林" en="Yulin" />
            <city id="101301001" name="百色" en="Baise" />
            <city id="101300701" name="贺州" en="Hezhou" />
            <city id="101301201" name="河池" en="Hechi" />
            <city id="101300401" name="来宾" en="Laibin" />
            <city id="101300201" name="崇左" en="Chongzuo" />
        </area>
        <area id="Hainan" name="海南省" en="Hainan">
            <city id="101310101" name="海口" en="Haikou" />
            <city id="101310201" name="三亚" en="Sanya" />
            <city id="101310211" name="琼海" en="Qionghai" />
            <city id="101310204" name="澄迈" en="Chengmai" />
            <city id="101310214" name="保亭" en="Baoting" />
            <city id="101310203" name="临高" en="Lingao" />
            <city id="101310210" name="屯昌" en="Tunchang" />
            <city id="101310216" name="陵水" en="Lingshui" />
            <city id="101310207" name="白沙" en="Baisha" />
            <city id="101310222" name="五指山" en="Wuzhishan" />
            <city id="101310221" name="乐东" en="Ledong" />
            <city id="101310209" name="定安" en="Dingan" />
            <city id="101310202" name="东方" en="Dongfang" />
            <city id="101310206" name="昌江" en="Changjiang" />
            <city id="101310205" name="儋州" en="Danzhou" />
            <city id="101310215" name="万宁" en="Wanning" />
            <city id="101310212" name="文昌" en="Wenchang" />
            <city id="101310208" name="琼中" en="Qiongzhong" />
            <city id="101310217" name="西沙" en="Xisha" />
            <city id="101310220" name="南沙" en="Nansha" />
        </area>
        <area id="Sichuan" name="四川省" en="Sichuan">
            <city id="101270101" name="成都" en="Chengdu" />
            <city id="101270301" name="自贡" en="Zigong" />
            <city id="101270201" name="攀枝花" en="Panzhihua" />
            <city id="101271001" name="泸州" en="Luzhou" />
            <city id="101272001" name="德阳" en="Deyang" />
            <city id="101270401" name="绵阳" en="Mianyang" />
            <city id="101272101" name="广元" en="Guangyuan" />
            <city id="101270701" name="遂宁" en="Suining" />
            <city id="101271201" name="内江" en="Neijiang" />
            <city id="101271401" name="乐山" en="Leshan" />
            <city id="101270501" name="南充" en="Nanchong" />
            <city id="101271101" name="宜宾" en="Yibin" />
            <city id="101270801" name="广安" en="Guangan" />
            <city id="101270601" name="达州" en="Dazhou" />
            <city id="101270901" name="巴中" en="Bazhong" />
            <city id="101271701" name="雅安" en="Yaan" />
            <city id="101271501" name="眉山" en="Meishan" />
            <city id="101271301" name="资阳" en="Ziyang" />
            <city id="101271304" name="简阳" en="Jianyang" />
            <city id="101271901" name="阿坝" en="Aba" />
            <city id="101271906" name="九寨沟" en="Jiuzhaigou" />
            <city id="101271801" name="甘孜" en="Ganzi" />
            <city id="101271601" name="凉山" en="Liangshan" />
            <city id="101271409" name="峨眉山" en="Emeishan" />
            <city id="101043400" name="酉阳" en="Youyang" />
        </area>
        <area id="Guizhou" name="贵州省" en="Guizhou">
            <city id="101260101" name="贵阳" en="Guiyang" />
            <city id="101260801" name="六盘水" en="Liupanshui" />
            <city id="101260201" name="遵义" en="Zunyi" />
            <city id="101260301" name="安顺" en="Anshun" />
            <city id="101260601" name="铜仁" en="Tongren" />
            <city id="101260701" name="毕节" en="Bijie" />
            <city id="101260902" name="晴隆" en="Qinglong" />
            <city id="101260401" name="都匀" en="Duyun" />
            <city id="101260501" name="凯里" en="Kaili" />
            <city id="101260515" name="锦屏" en="Jinping" />
            <city id="101260901" name="兴义" en="Xingyi" />
        </area>
        <area id="Yunnan" name="云南省" en="Yunnan">
            <city id="101290101" name="昆明" en="Kunming" />
            <city id="101290401" name="曲靖" en="Qujing" />
            <city id="101290701" name="玉溪" en="Yuxi" />
            <city id="101291001" name="昭通" en="Zhaotong" />
            <city id="101290801" name="楚雄" en="Chuxiong" />
            <city id="101290301" name="红河" en="Honghe" />
            <city id="101291401" name="丽江" en="Lijiang" />
            <city id="101291601" name="西双版纳" en="Sipsong Panna" />
            <city id="101291301" name="香格里拉" en="Xianggelila" />
            <city id="101290601" name="文山" en="Wenshan" />
            <city id="101290201" name="大理" en="Dali" />
            <city id="101290501" name="保山" en="Baoshan" />
            <city id="101291101" name="临沧" en="Lincang" />
            <city id="101290901" name="普洱" en="Puer" />
            <city id="101291004" name="镇雄" en="Zhenxiong" />
        </area>
        <area id="Tibet" name="西藏" en="Tibet">
            <city id="101140101" name="拉萨" en="Lhasa" />
            <city id="" name="昌都" en="Changdu" />
            <city id="101140201" name="日喀则" en="ShiGaTse" />
            <city id="101140601" name="那曲" en="Naqu" />
            <city id="" name="林芝" en="Linzhi" />
        </area>
        <area id="Shaanxi" name="陕西省" en="Shaanxi">
            <city id="101110101" name="西安" en="Xian" />
            <city id="101110200" name="咸阳" en="Xianyang" />
            <city id="101110901" name="宝鸡" en="Baoji" />
            <city id="101110501" name="渭南" en="Weinan" />
            <city id="101111001" name="铜川" en="Tongchuan" />
            <city id="101110601" name="商洛" en="Shangluo" />
            <city id="101110300" name="延安" en="Yanan" />
            <city id="101110801" name="汉中" en="Hanzhong" />
            <city id="101110701" name="安康" en="Ankang" />
            <city id="101110401" name="榆林" en="Yulin" />
        </area>
        <area id="Gansu" name="甘肃省" en="Gansu">
            <city id="101160101" name="兰州" en="Lanzhou" />
            <city id="101160601" name="金昌" en="Jinchang" />
            <city id="101161301" name="白银" en="Baiying" />
            <city id="101160901" name="天水" en="Tianshui" />
            <city id="101160501" name="武威" en="Wuwei" />
            <city id="101160701" name="张掖" en="Zhangye" />
            <city id="101160801" name="酒泉" en="Jiuquan" />
            <city id="101160301" name="平凉" en="Pingliang" />
            <city id="101160401" name="庆阳" en="Qingyang" />
            <city id="101160201" name="定西" en="Dingxi" />
            <city id="101161101" name="临夏" en="Linxia" />
            <city id="101161401" name="嘉峪关" en="Jiayuguan" />
        </area>
        <area id="Qinghai" name="青海省" en="Qinghai">
            <city id="101150101" name="西宁" en="Xining" />
            <city id="101150702" name="格尔木" en="Geermu" />
            <city id="101150601" name="玉树" en="Yushu" />
        </area>
        <area id="Ningxia" name="宁夏" en="Ningxia">
            <city id="101170101" name="银川" en="Yinchuan" />
            <city id="101170201" name="石嘴山" en="Shizuishan" />
            <city id="101170401" name="固原" en="Guyuan" />
            <city id="101170301" name="吴忠" en="Wuzhong" />
            <city id="101170501" name="中卫" en="Zhongwei" />
        </area>
        <area id="Xinjiang" name="新疆" en="Xinjiang">
            <city id="101130101" name="乌鲁木齐" en="Wulumuqi" />
            <city id="101130201" name="克拉玛依" en="Karamay" />
            <city id="101130501" name="吐鲁番" en="Turpan" />
            <city id="101131201" name="哈密" en="Hami" />
            <city id="101131301" name="和田" en="Hotan" />
            <city id="101130801" name="阿克苏" en="Aksu" />
            <city id="101130901" name="喀什" en="Kashi" />
            <city id="101130601" name="库尔勒" en="Kuerle" />
            <city id="101130401" name="昌吉" en="Changji" />
            <city id="101131601" name="博乐" en="Bole" />
            <city id="101131101" name="塔城" en="Tacheng" />
            <city id="101131401" name="阿勒泰" en="Altay" />
            <city id="101130301" name="石河子" en="Shihezi" />
            <city id="101131001" name="伊宁" en="Yining" />
            <city id="101131011" name="奎屯" en="Kuitun" />
            <city id="101131501" name="阿图什" en="Artux" />
            <city id="101131502" name="乌恰" en="Wuqia" />
            <city id="101131503" name="阿克陶" en="Aketao" />
            <city id="101131504" name="阿合奇" en="Aheqi" />
        </area>
        <area id="Taiwan" name="台湾" en="Taiwan">
            <city id="101340101" name="台北" en="Taipei" />
            <city id="101340201" name="高雄" en="Kaohsiung" />
            <city id="101340401" name="台中" en="Taichung" />
            <city id="101340203" name="台南" en="Tainan" />
            <city id="101340204" name="台东" en="Taitung" />
            <city id="TWXX0003" name="基隆" en="Chilung" />
            <city id="101340405" name="花莲" en="Hualien" />
            <city id="101340103" name="新竹" en="Hsinchu" />
            <city id="101340202" name="嘉义" en="Chiayi" />
        </area>
    </country>
    <country id="United States" name="美国" en="United States">
        <area id="NY" name="纽约" en="NY">
            <city id="USNY0996" name="纽约" en="New York" />
        </area>
        <area id="DC" name="哥伦比亚特区" en="DC">
            <city id="USDC0001" name="华盛顿" en="Washington" />
        </area>
        <area id="CA" name="加利福尼亚" en="CA">
            <city id="USCA0987" name="旧金山" en="San Francisco" />
            <city id="USCA0638" name="洛杉矶" en="Los Angeles" />
            <city id="USCA0403" name="弗里蒙特" en="Fremont" />
            <city id="USCA0830" name="帕洛阿尔托" en="Palo Alto" />
            <city id="USCA1116" name="森尼维耳" en="Sunnyvale" />
        </area>
        <area id="GA" name="乔治亚" en="GA">
            <city id="USGA0028" name="亚特兰大" en="Atlanta" />
        </area>
        <area id="MA" name="马萨诸塞" en="MA">
            <city id="USMA0046" name="波士顿" en="Boston" />
        </area>
        <area id="WA" name="华盛顿" en="WA">
            <city id="USWA0395" name="西雅图" en="Seattle" />
        </area>
        <area id="HI" name="夏威夷" en="HI">
            <city id="USHI0026" name="火奴鲁鲁" en="Honolulu" />
        </area>
    </country>
    <country id="Europe" name="欧洲" en="Europe">
        <area id="United Kingdom" name="英国" en="United Kingdom">
            <city id="UKXX0085" name="伦敦" en="London" />
            <city id="UKXX0015" name="贝尔法斯特" en="Belfast" />
            <city id="UKXX0052" name="爱丁堡" en="Edinburgh" />
            <city id="UKXX0030" name="卡迪夫" en="Cardiff" />
            <city id="UKXX0976" name="圣安德鲁斯" en="St Andrews" />
        </area>
        <area id="Germany" name="德国" en="Germany">
            <city id="GMXX0007" name="柏林" en="Berlin" />
            <city id="GMXX0010" name="波恩" en="Bonn" />
            <city id="GMXX0028" name="杜塞尔多夫" en="Dusseldorf" />
            <city id="GMXX0040" name="法兰克福" en="Frankfurt" />
            <city id="GMXX0049" name="汉堡" en="Hamburg" />
            <city id="GMXX0051" name="汉诺威" en="Hannover" />
            <city id="GMXX0018" name="科隆" en="Koln" />
            <city id="GMXX0072" name="莱比锡" en="Leipzig" />
            <city id="GMXX0128" name="斯图加特" en="Stuttgart" />
            <city id="GMXX0024" name="多特蒙德" en="Dortmund" />
            <city id="GMXX0096" name="纽伦堡" en="Nurnberg" />
            <city id="GMXX0087" name="慕尼黑" en="Munchen" />
            <city id="GMXX0014" name="不莱梅" en="Bremen" />
        </area>
        <area id="EuropeOthers" name="其他" en="EuropeOthers">
            <city id="FRXX0076" name="巴黎" en="Paris" />
            <city id="EGXX0004" name="开罗" en="Cairo" />
            <city id="SPXX0050" name="马德里" en="Madrid" />
            <city id="RSXX0063" name="莫斯科" en="Moscow" />
            <city id="ITXX0067" name="罗马" en="Rome" />
            <city id="NLXX0002" name="阿姆斯特丹" en="Amsterdam" />
            <city id="EZXX0012" name="布拉格" en="Prague" />
            <city id="DAXX0009" name="哥本哈根" en="Copenhagen" />
            <city id="NOXX0029" name="奥斯陆" en="Oslo" />
            <city id="SWXX0031" name="斯德哥尔摩" en="Stockholm" />
            <city id="GRXX0004" name="雅典" en="Athens" />
            <city id="SZXX0006" name="伯尔尼" en="Berne" />
            <city id="ICXX0002" name="雷克雅未克" en="Reykjavik" />
            <city id="HUXX0002" name="布达佩斯" en="Budapest" />
            <city id="TUXX0014" name="伊斯坦布尔" en="Istanbul" />
            <city id="MNXX0001" name="摩纳哥" en="Monaco" />
            <city id="BEXX0005" name="布鲁塞尔" en="Brussels" />
            <city id="EIXX0014" name="都柏林" en="Dublin" />
            <city id="LUXX0003" name="卢森堡" en="Luxembourg" />
            <city id="POXX0016" name="里斯本" en="Lisbon" />
            <city id="AUXX0025" name="维也纳" en="Vienna" />
        </area>
    </country>
    <country id="Asia" name="亚洲" en="Asia">
        <area id="Japan" name="日本" en="Japan">
            <city id="JAXX0085" name="东京" en="Tokyo" />
            <city id="JAXX0078" name="札幌" en="Sapporo" />
            <city id="JAXX0004" name="青森" en="Aomori" />
            <city id="JAXX0104" name="仙台" en="Sendai" />
            <city id="JAXX0071" name="大阪" en="Osaka" />
            <city id="JAXX0009" name="福冈" en="Fukuoka" />
            <city id="JAXX0057" name="名古屋" en="Nagoya" />
            <city id="JAXX0040" name="神户" en="Kobe" />
        </area>
        <area id="Malaysia" name="马来西亚" en="Malaysia">
            <city id="MYXX0008" name="吉隆坡" en="Kuala Lumpur" />
            <city id="MYXX0001" name="彭亨" en="Batu Pahat" />
            <city id="MYXX0003" name="怡保" en="Ipoh" />
            <city id="MYXX0004" name="新山" en="Johor Bahru" />
            <city id="MYXX0009" name="登嘉" en="Kuala Terengganu" />
            <city id="MYXX0013" name="马六甲" en="Melaka" />
            <city id="MYXX0022" name="槟城" en="Penang" />
            <city id="MYXX0032" name="兰卡威" en="Langkawi" />
            <city id="MYXX0028" name="亚庇" en="Kota Kinabalu" />
            <city id="MYXX0005" name="加影" en="Kajang" />
            <city id="MYXX0010" name="关丹" en="Kuantan" />
            <city id="MYXX0011" name="古晋" en="Kuching" />
            <city id="MYXX0014" name="麻坡" en="Muar" />
            <city id="MYXX0017" name="芙蓉" en="Seremban" />
            <city id="MYXX0019" name="诗巫" en="Sibu" />
            <city id="MYXX0030" name="山打根" en="Sandakan" />
        </area>
        <area id="AsiaOthers" name="其他" en="AsiaOthers">
            <city id="INXX0038" name="新德里" en="Delhi" />
            <city id="SNXX0006" name="新加坡" en="Singapore" />
            <city id="KSXX0037" name="首尔" en="Seoul" />
            <city id="KNXX0006" name="平壤" en="Pyongyang" />
            <city id="THXX0002" name="曼谷" en="Bangkok" />
            <city id="THXX0003" name="清迈" en="Chiang Mai" />
            <city id="THXX0018" name="普吉" en="Phuket" />
            <city id="THXX0046" name="苏梅岛" en="Koh Samui" />
            <city id="THXX0015" name="芭堤雅" en="Pattaya" />
            <city id="IDXX0022" name="雅加达" en="Jakarta" />
            <city id="IDXX0005" name="巴厘岛" en="Bali" />
            <city id="VMXX0007" name="胡志明市" en="Ho Chi Minh" />
            <city id="VMXX0028" name="岘港" en="Da Nang" />
            <city id="CBXX0001" name="金边" en="Phnom Penh" />
            <city id="QAXX0003" name="多哈" en="Doha" />
            <city id="RPXX0017" name="马尼拉" en="Manila" />
            <city id="RPXX0007" name="宿务" en="Cebu" />
            <city id="NPXX0002" name="加德满都" en="Kathmandu" />
            <city id="CEXX0001" name="科伦坡" en="Colombo" />
            <city id="VMXX0006" name="河内" en="Hanoi" />
            <city id="MVXX0001" name="马累" en="Male" />
            <city id="AEXX0004" name="迪拜" en="Dubai" />
            <city id="TUXX0002" name="安卡拉" en="Ankara" />
            <city id="USMP0001" name="塞班岛" en="Saipan" />
            <city id="USGU0008" name="关岛" en="Guahan" />
            <city id="BXXX0001" name="斯里巴加湾市" en="Bandar Seri Begawan" />
        </area>
    </country>
    <country id="Others" name="其他" en="Others">
        <area id="Canada" name="加拿大" en="Canada">
            <city id="CAXX0504" name="多伦多" en="Toronto" />
            <city id="CAXX0343" name="渥太华" en="Ottawa" />
            <city id="CAXX0518" name="温哥华" en="Vancouver" />
            <city id="CAXX0547" name="温尼泊" en="Winnipeg" />
            <city id="CAXX0044" name="布兰顿" en="Brandon" />
        </area>
        <area id="Africa" name="非洲" en="Africa">
            <city id="SFXX0010" name="开普敦" en="Cape Town" />
            <city id="SFXX0023" name="约翰内斯堡" en="Johannesburg" />
            <city id="SFXX0044" name="比勒陀利亚" en="Pretoria" />
            <city id="SFXX0008" name="布隆方丹" en="Bloemfontein" />
            <city id="MPXX0005" name="毛里求斯" en="Mauritius" />
            <city id="KEXX0009" name="内罗毕" en="Nairobi" />
            <city id="TSXX0010" name="突尼斯" en="Tunis" />
        </area>
        <area id="South America" name="南美洲" en="South America">
            <city id="BRXX0043" name="巴西利亚" en="Brasilia" />
            <city id="BRXX0232" name="圣保罗" en="Sao Paulo" />
            <city id="BRXX0201" name="里约热内卢" en="Rio de Janeiro" />
            <city id="MXDF0132" name="墨西哥城" en="Mexico City" />
            <city id="HAXX0004" name="太子港" en="Port-au-Prince" />
            <city id="ARBA0009" name="布宜诺斯艾利斯" en="Buenos Aires" />
        </area>
        <area id="Oceania" name="大洋洲" en="Oceania">
            <city id="ASXX0112" name="悉尼" en="Sydney" />
            <city id="ASXX0075" name="墨尔本" en="Melbourne" />
            <city id="ASXX0023" name="堪培拉" en="Canberra" />
            <city id="ASXX0016" name="布里斯班" en="Brisbane" />
            <city id="ASXX0001" name="阿德莱德" en="Adelaide" />
            <city id="NZXX0049" name="惠灵顿" en="Wellington" />
            <city id="FJXX0009" name="斐济" en="Fiji" />
            <city id="FPXX0001" name="大溪地" en="Tahiti" />
        </area>
    </country>
</root>
        


package com.test;

import java.io.File;
import java.util.Iterator;
import java.util.List;

import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;

public class ReadXML {
	public static void main(String[] args) {
		ReadXML xml=new ReadXML();
		try {
			xml.readXMLfile("D:\\city.xml");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void readXMLfile(String filePath) throws Exception{
		File xmlFile=new File(filePath);
		SAXReader reader=new SAXReader();    
		Document xmlDoc=reader.read(xmlFile);    // Read xml stream
	    Element root=xmlDoc.getRootElement();    //Get the root node  of XML File
	    int j=0;
	    List listRowSet=xmlDoc.selectNodes("//country[1]//area//city");
	    for(Iterator i=listRowSet.iterator();i.hasNext();){
	     Element ele=(Element)i.next();
	     System.out.println("Test   "+ele.getName());
	     j++;
	    }
	}
}

关于selectNodes这个方法参数具体见

http://www.w3school.com.cn/xpath/xpath_syntax.asp



分享到:
评论

相关推荐

    dom4j解析xml文件(增删改查)

    在“dom4j解析xml文件(增删改查)”这个主题中,我们将深入探讨如何使用DOM4J来实现XML文档的四种基本操作:增加元素、删除元素、更新元素内容以及查询元素。 首先,让我们了解DOM4J的基本用法。在解析XML文件时,...

    dom4j解析xml文件的压缩包

    5. **事件驱动解析(SAX)**:除了传统的DOM解析外,DOM4J还支持SAX解析器,这种解析方式适用于处理大型XML文件,因为它不需要一次性加载整个文档到内存。 6. **Namespace支持**:DOM4J提供了对XML命名空间的全面...

    dom4j解析xml详解

    ### DOM4J解析XML详解 #### 一、DOM4J简介与特性 DOM4J是一个由dom4j.org开发的开源XML解析包,专为Java平台设计,它不仅支持DOM、SAX和JAXP标准,还巧妙地融入了Java集合框架,使其成为Java开发者在处理XML数据时...

    dom4j解析xml文件代码示例

    在本示例中,我们将深入探讨如何使用DOM4J解析XML文件,以`CacheInit.java`作为我们的核心代码示例,并参考`emailTemplateConfig.xml`作为实际操作的对象。 首先,让我们了解XML(eXtensible Markup Language)。...

    dom4j-jar与dom4j解析xml文档介绍

    "以及解析xml文档所用的pdf文档说明"则表明还有一个PDF文档,可能详细介绍了如何使用dom4j来解析XML文件,包括各种方法、类和接口的使用示例。 **dom4j解析XML文档知识点:** 1. **dom4j简介**:dom4j是一个开放...

    用dom4j解析xml文件

    本篇文章将深入探讨如何使用DOM4J来解析XML文件,以及通过示例代码来展示其基本操作。 首先,我们需要理解DOM4J的工作原理。DOM4J采用的是DOM(Document Object Model)模型,它将整个XML文档加载到内存中形成一棵...

    分别使用DOM和DOM4j解析XML文件

    以下是如何使用DOM4j解析XML: 1. 引入DOM4j库(如:dom4j-1.6.1.jar)。 2. 创建DocumentFactory实例。 3. 使用DocumentFactory的read()方法读取XML文件,得到Document对象。 4. 使用Document对象提供的方法(如...

    使用DOM4j解析XML文件

    在使用DOM4j解析XML文件时,首先需要导入DOM4j的相关包,如`SAXReader`用于读取XML文件,`Document`表示整个XML文档,`Element`表示XML文档中的元素,以及`Attribute`表示元素的属性。以下是一个使用DOM4j解析XML...

    dom4j解析XML文档.ppt

    DOM4J是一个强大的Java库,专门用于解析XML文档。它提供了简单易用的API,使得开发者可以更加方便地处理XML数据。DOM4J的核心优势在于它的面向接口编程设计,这使得它能够在不同的解析机制间灵活切换,如DOM、SAX和...

    dom4j解析xml,利用反射机制

    通过这种方式,我们可以利用DOM4J解析XML文件,同时借助Java反射机制将解析结果动态地映射到自定义的Java类中。这在处理XML数据时提供了很大的灵活性,尤其在需要将XML数据与业务对象关联时,反射机制显得尤为重要。

    dom4j 解析写入xml

    1、xml文档解析 2、 dom4j解析xml 3、实现xml文件解析 xml字符串解析 xml MAP键值对解析 4、实现xml写入与生成文件

    dom4j 解析xml实例

    在这个实例中,我们将深入探讨如何使用DOM4J解析XML文件,并通过`Dom4jTest1.java`这个示例程序来理解其工作原理。 首先,我们需要了解XML(Extensible Markup Language)是一种标记语言,常用于存储和传输数据。...

    Java使用sax、dom、dom4j解析xml文档

    以下是一个DOM4J解析XML的简单示例: ```java import org.dom4j.Document; import org.dom4j.DocumentHelper; import org.dom4j.Element; public class Dom4jExample { public static void main(String[] args) {...

    java dom4j解析xml

    Java DOM4J解析XML是一种常见的处理XML文档的技术,它提供了灵活且高效的API,使得开发者能够方便地读取、写入、修改以及操作XML文件。DOM4J是Java中一个非常强大的XML处理库,它结合了DOM、SAX和JDOM的优点,同时也...

    dom4j 解析(读取) xml 节点数据

    要开始解析XML文件,首先需要导入DOM4J的相关包: ```java import org.dom4j.Document; import org.dom4j.DocumentException; import org.dom4j.Element; import org.dom4j.io.SAXReader; ``` 接下来,我们将创建...

    DOM4J 解析XML

    **DOM4J解析XML** DOM4J是一个强大的Java库,专门用于处理XML文档。它提供了灵活、高效且功能丰富的API,使得XML的读取、创建、修改和查询变得简单易行。DOM4J的主要特点包括对XPath的支持、事件驱动的解析、以及与...

    dom4j解析xml实例

    **DOM4J解析XML实例详解** 在Java编程中,处理XML文档是一项常见的任务。DOM4J是一个非常流行的、强大的Java XML API,它提供了灵活且高效的方式来解析、创建、修改XML文档。本文将深入探讨如何使用DOM4J进行XML...

    dom4j解析xml

    ### DOM4J解析XML知识点详解 #### 一、DOM4J简介 DOM4J是一个Java库,用于处理XML文档。它的设计目标是为了提供一个简单、易于使用的API来处理XML文件,同时保持性能上的优势。与Java标准库中的DOM实现相比,DOM4J...

    dom4j解析XML所需jar包

    DOM4J是一个强大的Java库,专门用于处理XML文档。它提供了灵活且高效的API,使得XML的解析、创建、修改和查询变得简单。DOM4J的名字来源于DOM(Document Object Model)和Java的结合,但它的设计理念比标准DOM更先进...

Global site tag (gtag.js) - Google Analytics