WOEID

//
//  WOEID.swift
//  WOEID
//
//  Created by Park on 11/21/15.
//  Copyright © 2015 Park. All rights reserved.
//

import Foundation

class WOEID {
var code: Int64 = 0
var city: String = “”
var country: String = “”
var latitude: Double = 0.0
var longitude: Double = 0.0

init() {
}

init(code: Int64, city: String, country: String, latitude: Double, longitude: Double) {
self.code = code
self.city = city
self.country = country
self.latitude = latitude
self.longitude = longitude
}

var description : String {
get {
return “\(code),\(city),\(country),\(latitude),\(longitude)”
}
}

var xmlFormat : String {
get {
/*
let root = NSXMLElement(name: “WOEID”)
let xml = NSXMLDocument(rootElement: root)
root.addChile(NSXMLElement(name: “Code”, stringValue: “\(code)”))
root.addChile(NSXMLElement(name: “City”, stringValue: “\(city)”))
root.addChile(NSXMLElement(name: “Country”, stringValue: “\(country)”))
root.addChile(NSXMLElement(name: “Latitude”, stringValue: “\(latitude)”))
root.addChile(NSXMLElement(name: “Longitude”, stringValue: “\(longitude)”))
return xml.XMLString
*/
var xmlString = “<WOEID>\n”
xmlString += “<Code>\(self.code)</Code>\n”
xmlString += “<City>\(self.city)</City>\n”
xmlString += “<Country>\(self.country)</Country>\n”
xmlString += “<Latitude>\(self.latitude)</Latitude>\n”
xmlString += “<Longitude>\(self.longitude)</Longitude>\n”
xmlString += “</WOEID>\n”
return xmlString
}
}

}

Leave a Reply

Your email address will not be published. Required fields are marked *