我有以下响应作为xml我需要映射到 java对象我尝试使用jaxb,sax,dom无法从下面获取数据 FIELD NAME =“strShipmentNo”VALUE =“A134535”/数据.请建议如何从xml以下检索数据 DTDCREPLY CONSIGNMENT CNHEADER
<DTDCREPLY> <CONSIGNMENT> <CNHEADER> <CNTRACK>TRUE</CNTRACK> <FIELD NAME="strShipmentNo" VALUE="A15082271" /> <FIELD NAME="strRefNo" VALUE="N/A" /> <FIELD NAME="strMode" VALUE="AIR" /> <FIELD NAME="strOrigin" VALUE="LEAK-PROOF ENGINEERING PVT.LTD, AHMEDABAD" /> <FIELD NAME="strOriginRemarks" VALUE="Received from" /> <FIELD NAME="strBookedOn" VALUE="08072009" /> <FIELD NAME="strPieces" VALUE="1" /> <FIELD NAME="strWeightUnit" VALUE="Kg" /> <FIELD NAME="strWeight" VALUE="0.020" /> <FIELD NAME="strDestination" VALUE="PUNE" /> <FIELD NAME="strStatus" VALUE="DELIVERY" /> <FIELD NAME="strStatusTransOn" VALUE="09072009" /> <FIELD NAME="strStatusTransTime" VALUE="1210" /> <FIELD NAME="strRemarks" VALUE="CO SEAL" /> <FIELD NAME="strNoOfAttempts" VALUE="" /> </CNHEADER> <CNBODY> <CNACTIONTRACK>TRUE</CNACTIONTRACK> <CNACTION> <FIELD NAME="strAction" VALUE="DISPATCHED" /> <FIELD NAME="strRemarks" VALUE="" /> </CNACTION> <CNACTION> <FIELD NAME="strAction" VALUE="RECEIVED" /> <FIELD NAME="strRemarks" VALUE="" /> </CNACTION> <CNACTION> <FIELD NAME="strAction" VALUE="DISPATCHED" /> <FIELD NAME="strRemarks" VALUE="" /> </CNACTION> <CNACTION> <FIELD NAME="strAction" VALUE="RECEIVED" /> <FIELD NAME="strRemarks" VALUE="" /> </CNACTION> <CNACTION> <FIELD NAME="strAction" VALUE="OUT FOR DELIVERY" /> <FIELD NAME="strRemarks" VALUE="" /> </CNACTION> </CNBODY> </CONSIGNMENT> </DTDCREPLY>使用 XStream,您可以序列化大多数Java对象而无需任何映射.对象名称成为生成的XML中的元素名称,类中的字符串构成XML的元素内容.使用XStream序列化的类不需要实现Serializable接口. XStream是一个序列化工具,而不是数据绑定工具,这意味着它不会从XML或XML架构定义(XSD)文件执行类生成.检查此Stackoverflow question