Last active
November 18, 2018 19:04
-
-
Save ShoMasegi/3ccea5c678a7e8aa04b22ff73f75d221 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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