2 回答
TA贡献1810条经验 获得超4个赞
这里是解码 HTML XML 文档的结果。这是我们需要解组的示例 HTML XML 文档。
<RTR>
<HEAD>
<IDCMS pn="ABF31A6FNCL0004" vers="4.0"/>
<DA>2018/12/11 00:15:42</DA>
<ACD MSN="0160" tail="N504DN" type="A350-900"/>
<TID>C00000023</TID>
</HEAD>
<HEADRTR>
<FROM>ZSPD</FROM>
<TO>KLAX</TO>
<FNBR>DAL88 </FNBR>
</HEADRTR>
<ITD>
<CB>A</CB>
<FDE disp="n" dm="y">
<MC>3031H050</MC>
<MD>A-ICE // > A-ICE SIDESLIP PROBE 2 HEATG</MD>
<DA>2018/12/11 00:12:42</DA>
<CDA>2018/12/11 00:14:17</CDA>
<FPH>8</FPH>
<LAB>1</LAB>
</FDE>
<MM fo="A" occ="5">
<MC>3413F7EV</MC>
<MD>PROBE-SSA,2(11FP2)</MD>
<DA>2018/12/11 00:08:43</DA>
<ATA>3413</ATA>
<FPH>8</FPH>
<FCL>1</FCL>
<PRIO>high</PRIO>
<STA>1</STA>
<SYS name="ADR2" bite_id="3" side="2"/>
</MM>
</ITD>
</RTR>
这是 Jaxb POJO 将 XML 映射到 POJO。
RTR
@XmlRootElement(name = "RTR", namespace="com.ge.ip.infra.fadec.jaxb.decoder")
public class Rtr implements Serializable {
private static final long serialVersionUID = 1L;
public Rtr() {
super();
}
private Itd itd;
private HeadRtr headRtr;
private Head head;
public Itd getItd() {
return itd;
}
public void setItd(Itd itd) {
this.itd = itd;
}
public HeadRtr getHeadRtr() {
return headRtr;
}
public void setHeadRtr(HeadRtr headRtr) {
this.headRtr = headRtr;
}
public Head getHead() {
return head;
}
public void setHead(Head head) {
this.head = head;
}
@Override
public String toString()
{
return "RTR ITD = " + itd + ", HEADRTR = " + headRtr + ", HEAD = " + head;
}
}
头
@XmlRootElement(name = "HEAD")
public class Head implements Serializable {
private static final long serialVersionUID = 1L;
@XmlElement(name = "IDCMS") private Idcms idcms;
@XmlElement(name = "DA") private String da;
@XmlElement(name = "ACD") private Acd acd;
@XmlElement(name = "TID") private String tid;
public String getDa() {
return da;
}
public String getTid() {
return tid;
}
public void setDa(String da) {
this.da = da;
}
public void setTid(String tid) {
this.tid = tid;
}
public Acd getAcd () {
return acd;
}
public void setAcd (Acd acd) {
this.acd = acd;
}
public Idcms getIdcms () {
return idcms;
}
public void setIdcms (Idcms idcms) {
this.idcms = idcms;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("DA=");
sb.append(getDa()).append(",");
sb.append("TID=").append(getTid()).append(",");
sb.append(acd.toString());
sb.append(idcms.toString());
return sb.toString();
}
//}
public class Idcms implements Serializable {
private static final long serialVersionUID = 1L;
@XmlAttribute(name = "pn") private String pn;
@XmlAttribute(name = "vers") private String vers;
public String getPn() {
return pn;
}
public String getVers() {
return vers;
}
public void setPn(String pn) {
this.pn = pn;
}
public void setVers(String vers) {
this.vers = vers;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("PN=");
sb.append(getPn()).append(",");
sb.append("VERS=").append(getVers());
return sb.toString();
}
}
public class Acd implements Serializable {
private static final long serialVersionUID = 1L;
@XmlAttribute(name = "MSN") private String msn;
@XmlAttribute(name = "tail") private String tail;
@XmlAttribute(name = "type") private String type;
public String getMsn() {
return msn;
}
public String getTail() {
return tail;
}
public String getType() {
return type;
}
public void setMsn(String msn) {
this.msn = msn;
}
public void setTail(String tail) {
this.tail = tail;
}
public void setType(String type) {
this.type = type;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("MSN=");
sb.append(getMsn()).append(",");
sb.append("TAIL=").append(getTail()).append(",");
sb.append("TYPE=").append(getType());
return sb.toString();
}
}
}
头部
@XmlRootElement( name = "HEADRTR" )
public class HeadRtr implements Serializable {
private static final long serialVersionUID = 1L;
private String from;
private String to;
private String fnbr;
HeadRtr(){
super();
}
HeadRtr(@XmlElement(name="FROM") String from,
@XmlElement(name="TO") String to,
@XmlElement(name="FNBR") String fnbr) {
this.from = from;
this.to = to;
this.fnbr = fnbr;
}
public String getFrom() {
return from;
}
public String getTo() {
return to;
}
public String getFnbr() {
return fnbr;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("FROM=");
sb.append(getFrom()).append(",");
sb.append("TO=").append(getTo()).append(",");
sb.append("FNBR=").append(getFnbr());
return sb.toString();
}
}
国际贸易发展署
@XmlRootElement( name = "ITD" )
@XmlAccessorType (XmlAccessType.FIELD)
public class Itd implements Serializable {
private static final long serialVersionUID = 1L;
private Mm mm;
private Fde fde;
private Nfde nfde;
public Mm getMm() {
return mm;
}
public void setMm (Mm mm)
{
this.mm = mm;
}
@XmlElement(name="CB")
private String cb;
public String getCb() {
return cb;
}
public void setCb(String cb) {
this.cb = cb;
}
public Fde getFde ()
{
return fde;
}
public void setFde (Fde fde)
{
this.fde = fde;
}
public Nfde getNfde() {
return nfde;
}
public void setNfde (Nfde nfde)
{
this.nfde = nfde;
}
@Override
public String toString()
{
return "ITD MM = " + mm + ", CB = " + cb + ", FDE = " + fde + ", NFDE = " + nfde;
}
}
NFDE
@XmlRootElement( name = "NFDE" )
@XmlAccessorType (XmlAccessType.FIELD)
public class Nfde implements Serializable {
private static final long serialVersionUID = 1L;
private String mc;
private String md;
public String getMc() {
if ( !mc.isEmpty() && null != mc ) {
return mc;
} else {
return "NFDE";
}
}
public String getMd() {
if ( !md.isEmpty() && null != md ) {
return md;
} else {
return "NFDE";
}
}
@XmlElement(name="MC")
public void setMc(String mc) {
this.mc = mc;
}
@XmlElement(name="MD")
public void setMd(String md) {
this.md = md;
}
}
FDE
@XmlRootElement( name = "FDE" )
@XmlAccessorType (XmlAccessType.FIELD)
public class Fde implements Serializable {
private static final long serialVersionUID = 1L;
private String mc;
private String md;
private String da;
private String fph;
Fde(){
super();
}
Fde( @XmlElement(name="MC") String mc,
@XmlElement(name="MD") String md,
@XmlElement(name="DA") String da,
@XmlElement(name="FPH") String fph) {
this.mc = mc;
this.md = md;
this.da = da;
this.fph = fph;
}
public String getMc() {
return mc;
}
public String getMd() {
return md;
}
public String getDa() {
return da;
}
public String getFph() {
return fph;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("MC=");
sb.append(getMc()).append(",");
sb.append("MD=").append(getMd()).append(",");
sb.append("DA=").append(getDa()).append(",");
sb.append("FPH=").append(getFph());
return sb.toString();
}
}
毫米
@XmlRootElement( name = "MM" )
@XmlAccessorType (XmlAccessType.FIELD)
public class Mm implements Serializable {
private static final long serialVersionUID = 1L;
private String mc;
private String md;
private String da;
private String ata;
private String fph;
private String prio;
Mm(){
super();
}
Mm( @XmlElement(name="MC") String mc,
@XmlElement(name="MD") String md,
@XmlElement(name="DA") String da,
@XmlElement(name="FPH") String fph,
@XmlElement(name="PRIO") String prio) {
this.mc = mc;
this.md = md;
this.da = da;
this.fph = fph;
this.prio = prio;
}
public String getMc() {
return mc;
}
public String getMd() {
return md;
}
public String getDa() {
return da;
}
public String getAta() {
return ata;
}
public String getFph() {
return fph;
}
public String getPrio() {
return prio;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("MC=");
sb.append(getMc()).append(",");
sb.append("MD=").append(getMd()).append(",");
sb.append("DA=").append(getDa()).append(",");
sb.append("ATA=").append(getAta()).append(",");
sb.append("FPH=").append(getFph()).append(",");
sb.append("PRIO=").append(getPrio());
return sb.toString();
}
}
解码器 POJO
public class A350Decoder implements Serializable {
private static final long serialVersionUID = 1L;
public A350Decoder() {
super();
}
private Rtr rtr;
public Rtr getRtr() {
return rtr;
}
public void setRtr(Rtr rtr) {
this.rtr = rtr;
}
@Override
public String toString()
{
return "A350Decoder RTR = " + rtr;
}
}
添加回答
举报