转换规则:
1.主要是Map与List的互相嵌套
2.同名称的节点会被装进List
如下面的xml文件:
- @H_404_20@<?xmlversion="1.0"encoding="UTF-8"?>
- <GmMail>
- template_id>2</to_address>test@corp.gm.comto_alias>tommessage>XML-未来世界Messagerecipient_name>xml-tomsend_address>xml-test@163.comsender_comp_name>xml-gmsubject>xml-helloguysselected_itemsitem_groupitem_url>http://china.gm.comitem_name>gm中文站item_desc>gm中文站descitem_desc2>gm中文站desc2item_desc3>gm中文站desc3item_desc4>gm中文站desc4items_source>products>http://www.gm.com>gm>gmdescattachmentsattachment-groupattachment_url @H_404_20@http://china.gm.com/pics/com.cn.gm/story/frsc.jpg
- attachment_name>黄晓豫attachment_descdesc1>attach-desc1desc2>attach-desc2desc3>attach-desc3desc4>attach-desc4 @H_404_20@http://china.gm.com/pics/com.cn.gm/story/wr.jpg
- >张中汉desc_groupdesc_item>desc_item_1>desc_item_2>desc_item_3>desc_item_4>desc_item_5>
转换后的的Map(转换成字符串的效果):
- @H_404_20@{message=XML-未来世界Message,selected_items={items_source=products,item_group=[{item_name=gm中文站,item_desc=gm中文站desc,item_desc2=gm中文站desc2,item_desc4=gm中文站desc4,item_url=http://china.gm.com,item_desc3=gm中文站desc3},{item_name=gm,item_desc=gmdesc,item_url=http://www.gm.com}]},to_alias=tom,desc_group={desc_item=[desc_item_1,desc_item_2,desc_item_3,desc_item_4,desc_item_5]},sender_comp_name=xml-gm,subject=xml-helloguys,to_address=test@corp.gm.com,template_id=2,attachments={attachment-group=[{attachment_url=http://china.gm.com/pics/com.cn.gm/story/frsc.jpg,attachment_name=黄晓豫,attachment_desc={desc3=attach-desc3,desc4=attach-desc4,desc1=attach-desc1,desc2=attach-desc2}},{attachment_url=http://china.gm.com/pics/com.cn.gm/story/wr.jpg,attachment_name=张中汉,attachment_desc=[{desc1=attach-desc1,desc2=attach-desc2},{desc1=attach-desc1,desc2=attach-desc2}]}]},recipient_name=xml-tom,send_address=xml-test@163.com}