将xml转为实体类List或者Map类List

这篇博客探讨了在接口服务开发中如何处理XML数据,作者选择了将XML映射到Map而非实体类,以更好地处理错误数据。提供了相应的实体类、工具类代码示例,以及将XML转换为实体类List和Map类List的主方法。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

最近通过xfire开发接口服务, 总是需要处理xml,在思索将xml映射到实体类中好还是映射到map中好,最后考虑到错误数据问题还是将xml映射到map中,代码贴出来 以供参考。

实体类

  

package com.yxw.xml.practice1.domain;

import java.util.Arrays;
import java.util.Date;

/**
 * @author yxw
 * @create 2018-08-16 10:28
 * @desc
 **/
public class Rkjbxx {
    private String id;
    private String name;
    private String sex;
    private int age;
    private Date birthday;
    private String no;
    private String sid;
    private String exp;
    private String result;
    private short ashort;
    private long along;
    private float afloat;
    private double adouble;
    private char achar;
    private boolean bool;
    private byte abyte;
    private byte[] bytes;

    public byte[] getBytes() {
        return bytes;
    }

    public void setBytes(byte[] bytes) {
        this.bytes = bytes;
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getSex() {
        return sex;
    }

    public void setSex(String sex) {
        this.sex = sex;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        this.age = age;
    }

    public Date getBirthday() {
        return birthday;
    }

    public void setBirthday(Date birthday) {
        this.birthday = birthday;
    }

    public String getNo() {
        return no;
    }

    public void setNo(String no) {
        this.no = no;
    }

    public String getSid() {
        return sid;
    }

    public void setSid(String sid) {
        this.sid = sid;
    }

    public String getExp() {
        return exp;
    }

    public void setExp(String exp) {
        this.exp = exp;
    }

    public String getResult() {
        return result;
    }

    public void setResult(String result) {
        this.result = result;
    }

    public short getAshort() {
        return ashort;
    }

    public void setAshort(short ashort) {
        this.ashort = ashort;
    }

    public long getAlong() {
        return along;
    }

    public void setAlong(long along) {
        this.along = along;
    }

    public float getAfloat() {
        return afloat;
    }

    public void setAfloat(float afloat) {
        this.afloat = afloat;
    }

    public double getAdouble() {
        return adouble;
    }

    public void setAdouble(double adouble) {
        this.adouble = adouble;
    }

    public char getAchar() {
        return achar;
    }

    public void setAchar(char achar) {
        this.achar = achar;
    }

    public boolean isBool() {
        return bool;
    }

    public void setBool(boolean bool) {
        this.bool = bool;
    }

    public byte getAbyte() {
        return
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值