       else if typeof(v) == "object" 
         hasChild = false
         $a.xml += ind + "<" + name
-        for key in v
+        for key of v
           # If element has "@" character at beginning it is an attribute
           if key.charAt(0) == "@"
             $a.xml += " " + key.substr(1) + "=\"" + v[key].toString() + "\""

      
      # If JSON element is just a string value
      else
         $a.xml += ind + "<" + name + ">" + v.toString() +  "</" + name + ">"
      $a.xml

    for elm in json
      xml += toXml(json[elm], elm, "");
    if tab? 
      xml.replace(/\t/g, tab)
    else

        
        # Continue on if JSON element has child elements
        if hasChild
          for key of v
            # If element key is of type text (no XML tag created)
            if key == "#text" or key == "$"
              $a.xml += v[key]
            else if key == "#cdata" 
              $a.xml += "<![CDATA[" + v[key] + "]]>"
            # Else if element is not an XML attribute it has children
            else if key.charAt(0) != "@"
              $a.xml += toXml v[key], key, ind+"\t"
            
          # Add indentation for new element if it is on a new line 
          if $a.xml.charAt($a.xml.length-1) == "\n"
