     }
 
     /**
-        Find an XML element at the current level by element name
-
-        :param: key The element name to index by
-
-        :returns: instance of XMLIndexer to match the element (or elements) found by key
+    Find an XML element at the current level by element name
+
+    :param: key The element name to index by
+
+    :returns: instance of XMLIndexer to match the element (or elements) found by key
     */
     public subscript(key: String) -> XMLIndexer {
         get {
             let userInfo = [NSLocalizedDescriptionKey: "XML Element Error: Incorrect key [\"\(key)\"]"]
             switch self {
             case .Element(let elem):
-                if let match = elem.elements[key] {
+                if let match = elem.children[key] {
                     if match.count == 1 {
                         return .Element(match[0])
                     }

    /// The attributes of the element
    public var attributes = [String:String]()

    var elements = [String:[XMLElement]]()

    /**
        Initialize an XMLElement instance

        :param: name The name of the element to be initialized

        :returns: a new instance of XMLElement
    */
    init(name: String) {
        self.name = name
    }

    /**
        Adds a new XMLElement underneath this instance of XMLElement

        :param: name The name of the new element to be added
        :param: withAttributes The attributes dictionary for the element being added

        :returns: The XMLElement that has now been added
    */
    func addElement(name: String, withAttributes attributes: NSDictionary) -> XMLElement {
        let element = XMLElement(name: name)

        if var group = elements[name] {
            group.append(element)
            elements[name] = group
        }
        else {
            elements[name] = [element]
        }

        for (keyAny,valueAny) in attributes {

/// Simple XML parser.
public class SWXMLHash {
    /**
    Method to parse XML passed in as a string.

    :param: xml The XML to be parsed

    :returns: An XMLIndexer instance that is used to look up elements in the XML
    */
    class public func parse(xml: String) -> XMLIndexer {
        return parse((xml as NSString).dataUsingEncoding(NSUTF8StringEncoding)!)
    }

    /**
    Method to parse XML passed in as an NSData instance.

    :param: xml The XML to be parsed

    :returns: An XMLIndexer instance that is used to look up elements in the XML
    */
    class public func parse(data: NSData) -> XMLIndexer {
        var parser = XMLParser()
