我是Kotlin的新手,他试图构建我的第一个Android应用程序。 我有一个XML字符串,我想解析为一个类。 xml来自soap Webservice调用,结果在名为xmlOut.pcReturnData的字符串中,如下所示:
<?xml version="1.0" ?><ShipmentDetail><Waybill><WaybillNumber>0087073606</WaybillNumber><ServiceType>ECONOMY ROAD</ServiceType><CurrentStatus>Proof of delivery</CurrentStatus><CurrentStatusCode>POD</CurrentStatusCode><DeliveredDate>18052017</DeliveredDate><DeliveredTime>1200</DeliveredTime><ReceiverName>PIET</ReceiverName><NumberOfPieces>3</NumberOfPieces><TotalWeight> 330.00</TotalWeight><Contents/><ManifestReference/><OriginSuburb>MILNERTON</OriginSuburb><OriginHub>ATL</OriginHub><DestinationSuburb>BLOEMFONTEIN</DestinationSuburb><DestinationHub>BFN</DestinationHub><ShipperReference>0087073606</ShipperReference><TrackingEvents><BranchCode>ATL</BranchCode><EventDate>15052017</EventDate><EventTime>1158</EventTime><EventDescription>Waybill Created</EventDescription><EventCode>WBLCRE</EventCode></TrackingEvents><TrackingEvents><BranchCode>ATL</BranchCode><EventDate>15052017</EventDate><EventTime>1224</EventTime><EventDescription>In Trip</EventDescription><EventCode>WBLALL</EventCode></TrackingEvents><TrackingEvents><BranchCode>CPT</BranchCode><EventDate>15052017</EventDate><EventTime>1530</EventTime><EventDescription>On Floor</EventDescription><EventCode>WBLDAL</EventCode></TrackingEvents><TrackingEvents><BranchCode>CPT</BranchCode><EventDate>15052017</EventDate><EventTime>2238</EventTime><EventDescription>In Trip</EventDescription><EventCode>WBLALL</EventCode></TrackingEvents><TrackingEvents><BranchCode>BFN</BranchCode><EventDate>16052017</EventDate><EventTime>1534</EventTime><EventDescription>On Floor</EventDescription><EventCode>WBLDAL</EventCode></TrackingEvents><TrackingEvents><BranchCode>BFN</BranchCode><EventDate>16052017</EventDate><EventTime>1858</EventTime><EventDescription>In Trip</EventDescription><EventCode>WBLALD</EventCode></TrackingEvents><TrackingEvents><BranchCode>BFN</BranchCode><EventDate>17052017</EventDate><EventTime>1722</EventTime><EventDescription>Comments captured</EventDescription><EventCode>WBLCOM</EventCode></TrackingEvents><TrackingEvents><BranchCode>BFN</BranchCode><EventDate>17052017</EventDate><EventTime>1726</EventTime><EventDescription>In Trip</EventDescription><EventCode>WBLALD</EventCode></TrackingEvents><TrackingEvents><BranchCode>BFN</BranchCode><EventDate>18052017</EventDate><EventTime>1835</EventTime><EventDescription>Waybill Delivered</EventDescription><EventCode>WBLDLV</EventCode></TrackingEvents><TrackingEvents><BranchCode>CHLR</BranchCode><EventDate>19052017</EventDate><EventTime>1047</EventTime><EventDescription>POD</EventDescription><EventCode>PODCRE</EventCode></TrackingEvents></Waybill></ShipmentDetail>
我创建的课程:
data class ShipmentDetail(val Waybill: Waybill?)
data class TrackingEventsList(val EventDate: Number?, val EventTime: Number?, val EventDescription: String?, val BranchCode: String?, val EventCode: String?)
data class Waybill(val TrackingEvents: List<TrackingEventsList>?, val WaybillNumber: String?, val CurrentStatus: String?, val ShipperReference: String?, val CurrentStatusCode: String?, val ManifestReference: String?, val NumberOfPieces: Number?, val DeliveredDate: Number?, val OriginSuburb: String?, val TotalWeight: Number?, val Contents: String?, val DestinationSuburb: String?, val ServiceType: String?, val DestinationHub: String?, val DeliveredTime: Number?, val ReceiverName: String?, val OriginHub: String?)
我想从xml解析为ShipmentDetail类,在Kotlin中是否有XMLParser的构建,还是我需要使用某种插件或扩展?