Skip to content

Instantly share code, notes, and snippets.

@ShoMasegi
Last active November 18, 2018 19:04
Show Gist options
  • Save ShoMasegi/3ccea5c678a7e8aa04b22ff73f75d221 to your computer and use it in GitHub Desktop.
Save ShoMasegi/3ccea5c678a7e8aa04b22ff73f75d221 to your computer and use it in GitHub Desktop.
import Foundation
import SwiftyXMLParsable
struct Station {
var id: String
var name: String
var programs: [Program] = []
}
extension Station: XMLParsable {
// <station id="QRR">
// <name>文化放送</name>
// <progs>
// <prog> ... </prog>
// <prog> ... </prog>
// <progs>
// </station>
init(accessor: XML.Accessor) {
let id = accessor.attributes["id"] ?? ""
let name = accessor["name"].text ?? ""
let program = accessor["progs", "prog"].map { Program(accessor: $0) }
self.init(id: id, name: name, programs)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment