package intity;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;
import org.dom4j.Document;
import org.dom4j.DocumentException;
import org.dom4j.DocumentHelper;
import org.dom4j.Element;
import org.dom4j.io.SAXReader;
import pojo.B_OrderInfo;
import pojo.B_PassengerList;
import pojo.Buser_info;
import pojo.CCListe;
import pojo.CRListe;
import pojo.VListe;
public class Dom4jParse {
/**
* res
*
* @param xml
* @return
*/
@SuppressWarnings("rawtypes")
public static Buser_info res(String xml) {
Buser_info info=new Buser_info();
try {
SAXReader saxReader = new SAXReader();
Document doc = saxReader
.read("I:\\groovyworkspace\\Tests\\src\\intity\\priceRequest3.xml");
// Document doc = DocumentHelper.parseText(xml);//解析字符串
Element rootElt = doc.getRootElement();
Iterator iterator = rootElt.elementIterator();
while(iterator.hasNext()){
Element ele =(Element)iterator.next();
if(ele.getName().equalsIgnoreCase("B_OrderInfo"))info.setB_OrderInfo(getbo(ele.asXML()));
//
if(ele.getName().equalsIgnoreCase("B_PassengerList"))info.setB_PassengerListe(getbp(ele.asXML()));
if(ele.getName().equalsIgnoreCase("CC_List"))info.setcCListe(getbc(ele.asXML()));
if(ele.getName().equalsIgnoreCase("CR_List"))info.setcRListe(getbr(ele.asXML()));
if(ele.getName().equalsIgnoreCase("VList"))info.setvListe(getbv(ele.asXML()));
if(ele.getName().equalsIgnoreCase("json")){
System.out.println("json:"+ele.getStringValue()+" name:"+ele.attributeValue("name")+" id:"+ele.attributeValue("id"));
}
}
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return info;
}
@SuppressWarnings("rawtypes")
public static B_OrderInfo getbo(String xml){
B_OrderInfo info=new B_OrderInfo();
try {
Document doc = DocumentHelper.parseText(xml);
Element rootElt = doc.getRootElement();
Iterator iterator = rootElt.elementIterator();
while(iterator.hasNext()){
Element ele =(Element)iterator.next();
if(ele.getName().equalsIgnoreCase("BackPrice"))info.setBackPrice(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("Commission"))info.setCommission(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("CreateDt"))info.setCreateDt(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("FlowStep"))info.setFlowStep(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("LinkMan"))info.setLinkMan(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("OrderNo"))info.setOrderNo(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("ParentNo"))info.setParentNo(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("OrderType"))info.setOrderType(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("ProductType"))info.setProductType(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("Telphone"))info.setTelphone(ele.getStringValue());
}
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return info;
}
@SuppressWarnings("rawtypes")
public static List<B_PassengerList> getbp(String xml){
List<B_PassengerList> list=new ArrayList<B_PassengerList>();
try {
Document doc = DocumentHelper.parseText(xml);
Element rootElt = doc.getRootElement();
Iterator iterator = rootElt.elementIterator();
while(iterator.hasNext()){
Element elee =(Element)iterator.next();
if(elee.getName().equalsIgnoreCase("e")){
Iterator itera = elee.elementIterator();
B_PassengerList info=new B_PassengerList();
while(itera.hasNext()){
Element ele =(Element)itera.next();
if(ele.getName().equalsIgnoreCase("Birthday"))info.setBirthday(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("CabinPriceID"))info.setCabinPriceID(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("CabinRoomID"))info.setCabinRoomID(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("Gender"))info.setGender(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("IsBuyInsurance"))info.setIsBuyInsurance(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("IsChild"))info.setIsChild(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("IsCommissionVisa"))info.setIsCommissionVisa(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("PassengerID"))info.setPassengerID(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("Pinyin_Name"))info.setPinyin_Name(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("PsgName"))info.setPsgName(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("Tel"))info.setTel(ele.getStringValue());
}
list.add(info);
}
}
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
@SuppressWarnings("rawtypes")
public static List<CCListe> getbc(String xml){
List<CCListe> list=new ArrayList<CCListe>();
try {
Document doc = DocumentHelper.parseText(xml);
Element rootElt = doc.getRootElement();
Iterator iterator = rootElt.elementIterator();
while(iterator.hasNext()){
Element elee =(Element)iterator.next();
if(elee.getName().equalsIgnoreCase("e")){
Iterator itera = elee.elementIterator();
CCListe info=new CCListe();
while(itera.hasNext()){
Element ele =(Element)itera.next();
if(ele.getName().equalsIgnoreCase("Area"))info.setArea(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("BedType"))info.setBedType(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("CabinCode"))info.setCabinCode(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("CabinRoomCode"))info.setCabinRoomCode(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("CruiseCabinID"))info.setCruiseCabinID(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("Floor"))info.setFloor(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("HasWindow"))info.setHasWindow(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("IsCanAddBed"))info.setIsCanAddBed(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("PepoleNumber"))info.setPepoleNumber(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("ProxyPrice"))info.setProxyPrice(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("RoomType"))info.setRoomType(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("SingleRoomRatio"))info.setSingleRoomRatio(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("UnitPrice"))info.setUnitPrice(ele.getStringValue());
}
list.add(info);
}
}
} catch (DocumentException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
return list;
}
@SuppressWarnings("rawtypes")
public static List<CRListe> getbr(String xml){
List<CRListe> list=new ArrayList<CRListe>();
try {
Document doc = DocumentHelper.parseText(xml);
Element rootElt = doc.getRootElement();
Iterator iterator = rootElt.elementIterator();
while(iterator.hasNext()){
Element elee =(Element)iterator.next();
if(elee.getName().equalsIgnoreCase("e")){
Iterator itera = elee.elementIterator();
CRListe info=new CRListe();
while(itera.hasNext()){
Element ele =(Element)itera.next();
if(ele.getName().equalsIgnoreCase("CabinPriceId"))info.setCabinPriceId(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("CabinRoomId"))info.setCabinRoomId(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("IsUse"))info.setIsUse(ele.getStringValue());
if(ele.getName().equalsIgnoreCase("OrderNo"))info.setOrderNo(ele.getStringValue());
if(ele.getName().equals
xstream_dom4j_jdom_groovy解析xml
2星 需积分: 10 169 浏览量
2013-07-02
11:37:32
上传
评论
收藏 850KB RAR 举报
跑跑江湖打打酱油
- 粉丝: 1
- 资源: 9
最新资源
- 直接插入排序,冒泡排序,直接选择排序.zip
- 在排序2的基础上,再次对快排进行优化,其次增加快排非递归,归并排序,归并排序非递归版.zip
- 实现了7种排序算法.三种复杂度排序.三种nlogn复杂度排序(堆排序,归并排序,快速排序)一种线性复杂度的排序.zip
- 冒泡排序 直接选择排序 直接插入排序 随机快速排序 归并排序 堆排序.zip
- 课设-内部排序算法比较 包括冒泡排序、直接插入排序、简单选择排序、快速排序、希尔排序、归并排序和堆排序.zip
- Python排序算法.zip
- C语言实现直接插入排序、希尔排序、选择排序、冒泡排序、堆排序、快速排序、归并排序、计数排序,并带图详解.zip
- 常用工具集参考用于图像等数据处理
- 音乐展示网页、基于Stenography的图像数字水印添加与提取,以及基于颜色矩和Tamura算法的图像相似度评估算法py源码
- 基于EmguCV(OpenCV .net封装),图像数字水印加解密算法的实现,其中包含最低有效位算法,离散傅里叶变换算法+文档书
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈