in src/main/scala/pa/Parser.scala [536:583]
def parseStatsSummary(s: String): StatsSummary = {
def parseStat(node: NodeSeq): Stat = {
Stat(
home = (node \ "stat" \> "homeTotal").toInt,
away = (node \ "stat" \> "awayTotal").toInt,
statDescription = node \> "description",
statTypeId = node \@ "statsTypeID"
)
}
val nodes = XML.loadString(s) \\ "statsSummary" \ "statsType"
StatsSummary(
defence = PlayerStatsSummaryDefence(
backPasses = parseStat(nodes.filter(node => node \@ "statsTypeID" == "264")),
blocks = parseStat(nodes.filter(node => node \@ "statsTypeID" == "212")),
clearances = parseStat(nodes.filter(node => node \@ "statsTypeID" == "181")),
goalKicks = parseStat(nodes.filter(node => node \@ "statsTypeID" == "153")),
goalsAgainst = parseStat(nodes.filter(node => node \@ "statsTypeID" == "597")),
ownGoals = parseStat(nodes.filter(node => node \@ "statsTypeID" == "102")),
ownGoalsFor = parseStat(nodes.filter(node => node \@ "statsTypeID" == "596")),
saves = parseStat(nodes.filter(node => node \@ "statsTypeID" == "151"))
),
offence = PlayerStatsSummaryOffense(
assists = parseStat(nodes.filter(node => node \@ "statsTypeID" == "234")),
corners = parseStat(nodes.filter(node => node \@ "statsTypeID" == "190")),
crosses = parseStat(nodes.filter(node => node \@ "statsTypeID" == "148")),
freeKicks = parseStat(nodes.filter(node => node \@ "statsTypeID" == "159")),
goals = parseStat(nodes.filter(node => node \@ "statsTypeID" == "78")),
penalties = parseStat(nodes.filter(node => node \@ "statsTypeID" == "46")),
shotsOffTarget = parseStat(nodes.filter(node => node \@ "statsTypeID" == "164")),
shotsOnTarget = parseStat(nodes.filter(node => node \@ "statsTypeID" == "214")),
throwIns = parseStat(nodes.filter(node => node \@ "statsTypeID" == "144"))
),
discipline = PlayerStatsSummaryDiscipline(
bookings = parseStat(nodes.filter(node => node \@ "statsTypeID" == "37")),
dismissals = parseStat(nodes.filter(node => node \@ "statsTypeID" == "29")),
foulsAgainst = parseStat(nodes.filter(node => node \@ "statsTypeID" == "173")),
foulsCommitted = parseStat(nodes.filter(node => node \@ "statsTypeID" == "170")),
handBalls = parseStat(nodes.filter(node => node \@ "statsTypeID" == "255")),
offsides = parseStat(nodes.filter(node => node \@ "statsTypeID" == "156")),
tenYards = parseStat(nodes.filter(node => node \@ "statsTypeID" == "273"))
),
substitutionsOff = parseStat(nodes.filter(node => node \@ "statsTypeID" == "72")),
substitutionsOn = parseStat(nodes.filter(node => node \@ "statsTypeID" == "70")),
totalGoalsAgainst = parseStat(nodes.filter(node => node \@ "statsTypeID" == "599")),
totalGoalsFor = parseStat(nodes.filter(node => node \@ "statsTypeID" == "598"))
)
}