diff --git a/Sources/XmlElement.swift b/Sources/XmlElement.swift index a6ec462..8b7d8ed 100644 --- a/Sources/XmlElement.swift +++ b/Sources/XmlElement.swift @@ -11,12 +11,13 @@ import Foundation open class XmlElement { open var name: String open var attributes: [String:String] = [:] - open var text: String = "" //I guess this is ok. + open var text: String open var children: [XmlElement] = [] open var parent: XmlElement? - public init(name: String, xmlns: String? = nil) { + public init(name: String, xmlns: String? = nil, text: String = "") { self.name = name + self.text = text attributes["xmlns"] = xmlns } @@ -24,6 +25,15 @@ open class XmlElement { //TODO: generate compact xml return "<\(name)\(attributes.map({" \($0)=\"\($1)\" "}).joined())>\(text)\(children.map({ $0.description }).joined())" } + + open subscript(key: String) -> String? { + get { + return attributes[key] + } + set { + attributes[key] = newValue + } + } } extension XmlElement: CustomStringConvertible { diff --git a/Xml.swift.podspec b/Xml.swift.podspec index c257319..8fe6a27 100755 --- a/Xml.swift.podspec +++ b/Xml.swift.podspec @@ -1,6 +1,6 @@ Pod::Spec.new do |s| s.name = 'Xml.swift' - s.version = '1.0.0' + s.version = '1.1.0' s.summary = 'An XMLParser wrapper for swift.' s.homepage = 'https://github.com/BiAtoms/Xml.swift' s.license = { :type => 'MIT', :file => 'LICENSE' }