Skip to content

Instantly share code, notes, and snippets.

@matiangul
Created March 6, 2017 20:16
Show Gist options
  • Save matiangul/f70745e63fc994333c485dce116342df to your computer and use it in GitHub Desktop.
Save matiangul/f70745e63fc994333c485dce116342df to your computer and use it in GitHub Desktop.
Process xml content using java StAX API
while (xmlReader.hasNext()) {
xmlReader.next()
if (xmlReader.eventType == XMLStreamConstants.START_ELEMENT && xmlReader.localName == "F") {
origin = xmlReader.getAttributeValue(null, "o")
destination = xmlReader.getAttributeValue(null, "d")
route = xmlReader.getAttributeValue(null, "r")
} else if (xmlReader.eventType == XMLStreamConstants.START_ELEMENT && xmlReader.localName == "T") {
ticketCode = xmlReader.getAttributeValue(null, "t")
} else if (xmlReader.eventType == XMLStreamConstants.START_ELEMENT && xmlReader.localName == "FF") {
fulfilmentMethod = xmlReader.getAttributeValue(null, "fm")
withEffectFrom = xmlReader.getAttributeValue(null, "f")
withEffectUntil = xmlReader.getAttributeValue(null, "u")
publicAvailabilityDate = xmlReader.getAttributeValue(null, "p")
rcsProductReference = xmlReader.getAttributeValue(null, "k")
seasonTicketDetails = xmlReader.getAttributeValue(null, "s")
rcsFlows.put(RcsFlow(origin, destination, route, ticketCode, fulfilmentMethod, withEffectFrom,
withEffectUntil, publicAvailabilityDate, rcsProductReference, seasonTicketDetails))
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment