File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -11,19 +11,29 @@ import Foundation
11
11
open class XmlElement {
12
12
open var name : String
13
13
open var attributes : [ String : String ] = [ : ]
14
- open var text : String = " " //I guess this is ok.
14
+ open var text : String
15
15
open var children : [ XmlElement ] = [ ]
16
16
open var parent : XmlElement ?
17
17
18
- public init ( name: String , xmlns: String ? = nil ) {
18
+ public init ( name: String , xmlns: String ? = nil , text : String = " " ) {
19
19
self . name = name
20
+ self . text = text
20
21
attributes [ " xmlns " ] = xmlns
21
22
}
22
23
23
24
open var xml : String {
24
25
//TODO: generate compact xml
25
26
return " < \( name) \( attributes. map ( { " \( $0) = \" \( $1) \" " } ) . joined ( ) ) > \( text) \( children. map ( { $0. description } ) . joined ( ) ) </ \( name) > "
26
27
}
28
+
29
+ open subscript( key: String ) -> String ? {
30
+ get {
31
+ return attributes [ key]
32
+ }
33
+ set {
34
+ attributes [ key] = newValue
35
+ }
36
+ }
27
37
}
28
38
29
39
extension XmlElement : CustomStringConvertible {
Original file line number Diff line number Diff line change 1
1
Pod ::Spec . new do |s |
2
2
s . name = 'Xml.swift'
3
- s . version = '1.0 .0'
3
+ s . version = '1.1 .0'
4
4
s . summary = 'An XMLParser wrapper for swift.'
5
5
s . homepage = 'https://github.com/BiAtoms/Xml.swift'
6
6
s . license = { :type => 'MIT' , :file => 'LICENSE' }
You can’t perform that action at this time.
0 commit comments