 		 * @return 
 		 * 
 		 */
-		public function replace(propertyName:Object, value:XML):XML
+		public function replace(propertyName:Object, value:*):XML
+		{
+			/*
+				Semantics
+				When the replace method is called on an XML object x with parameters propertyName and value, the following steps are taken:
+				1. If x.[[Class]] ∈ {"text", "comment", "processing-instruction", "attribute"}, return x
+				2. If Type(value) ∉ {XML, XMLList}, let c = ToString(value)
+				3. Else let c be the result of calling the [[DeepCopy]] method of value
+				4. If ToString(ToUint32(P)) == P
+				  a. Call the [[Replace]] method of x with arguments P and c and return x
+				5. Let n be a QName object created as if by calling the function QName(P)
+				6. Let i = undefined
+				7. For k = x.[[Length]]-1 downto 0
+				  a. If ((n.localName == "*") or ((x[k].[[Class]] == "element") and (x[k].[[Name]].localName==n.localName))) and ((n.uri == null) or ((x[k].[[Class]] == "element") and (n.uri == x[k].[[Name]].uri )))
+				    i. If (i is not undefined), call the [[DeleteByIndex]] method of x with argument ToString(i)
+				    ii. Let i = k
+				8. If i == undefined, return x
+				9. Call the [[Replace]] method of x with arguments ToString(i) and c
+				10. Return x			
+			*/
+			if(_nodeKind == "text" || _nodeKind == "comment" || _nodeKind == "processing-instruction" || _nodeKind ==  "attribute")
+				return this;
+			if(value === null || value === undefined)
+				return this;
+			if((value is XML) || (value is XMLList))
+				value = value.copy();
+			else
+				value = value.toString();
+
+			return null;
+		}
+
+		private function replaceChild(idx:int,v:*):void
 		{
 			/*
 				When the [[Replace]] method of an XML object x is called with property name P and value V, the following steps are taken:

				  a. If V.[[Class]] is “element” and (V is x or an ancestor of x) throw an Error exception
				  b. Let V.[[Parent]] = x
				  c. If x has a property with name P
				    i. Let x[P].[[Parent]] = null
				  d. Let x[P] = V
				6. Else if Type(V) is XMLList
				  a. Call the [[DeleteByIndex]] method of x with argument P

		public function removeNamespace(ns:*):XML
		{
			/*
				Overview
				The removeNamespace method removes the given namespace from the in scope namespaces of this object and all its descendents,
				then returns a copy of this XML object. The removeNamespaces method will not remove a namespace from an object where it is referenced
				by that object’s QName or the QNames of that object’s attributes.
				Semantics
				When the removeNamespace method is called on an XML object x with parameter namespace, the following steps are taken:
				1. If x.[[Class]] ∈ {"text", "comment", "processing-instruction", "attribute"}, return x
				2. Let ns be a Namespace object created as if by calling the function Namespace( namespace )
