I have XML that I need to parse (I have no control over XML or its format):
<?xml version="1.0" encoding="UTF-8"?> <Siri xmlns="http://www.siri.org.uk/siri" version="1.3"> <ResponseTimestamp>2016-01-27T21:49:18.6841619-07:00</ResponseTimestamp> <VehicleMonitoringDelivery version="1.3"> <ResponseTimestamp>2016-01-27T21:49:18.6841619-07:00</ResponseTimestamp> <ValidUntil>2016-01-27T21:49:28.6841619-07:00</ValidUntil> <VehicleActivity> <RecordedAtTime>2016-01-27T21:49:18.6841619-07:00</RecordedAtTime> <MonitoredVehicleJourney> <LineRef>750</LineRef> <DirectionRef>SOUTHBOUND</DirectionRef> <FramedVehicleJourneyRef> <DataFrameRef>2016-01-27T00:00:00-07:00</DataFrameRef> <DatedVehicleJourneyRef>2519014</DatedVehicleJourneyRef> </FramedVehicleJourneyRef> <PublishedLineName>FRONTRUNNER</PublishedLineName> <OriginRef>601084</OriginRef> <DestinationRef>801164</DestinationRef> <Monitored>True</Monitored> <VehicleLocation> <Longitude>-111.86847</Longitude> <Latitude>40.401028</Latitude> </VehicleLocation> <ProgressRate>1</ProgressRate> <CourseOfJourneyRef>18127</CourseOfJourneyRef> <VehicleRef>101</VehicleRef> <MonitoredCall> <StopPointRef>801160</StopPointRef> <VisitNumber>1</VisitNumber> <VehicleAtStop>false</VehicleAtStop> </MonitoredCall> <OnwardCalls> <OnwardCall> <StopPointRef>23076</StopPointRef> <VisitNumber>1</VisitNumber> <StopPointName>OREM CENTRAL STATION</StopPointName> </OnwardCall> </OnwardCalls> <Extensions> <LastGPSFix>2016-01-27T21:49:09.473</LastGPSFix> <Scheduled>False</Scheduled> <Bearing>137.91188191173691</Bearing> <Speed>76.7898894465909</Speed> <DestinationName>Provo</DestinationName> </Extensions> </MonitoredVehicleJourney> </VehicleActivity> </VehicleMonitoringDelivery> </Siri>
I have a super base and truncated Vehicle class with nothing but a root element, for example:
import org.simpleframework.xml.Root; @Root(name="VehicleActivity") public class Vehicle { public Vehicle(){} }
From xml, I'm only interested in the data inside the VehicleActivity tag.
When I try to parse it, from the method of successfully processing the callback, I get the error message Attribute 'version' does not have a match in class :
01-28 12:49:48.561 30643-30643 E/MY_APP: org.simpleframework.xml.core.AttributeException: Attribute 'version' does not have a match in class com.eduardoflores.utarider.model.Vehicle at line 1
I know how to do this with JSON, but this is my first attempt to do this using an XML parser.
Any suggestions on what I'm doing wrong?
Thank you for the advanced.
source share