createElement('cart'); $cart = $doc->appendChild($cart); foreach ($MDA as $Item => $ItemName) { $book = $doc->createElement('book'); $book = $cart->appendChild($book); $title = $doc->createElement('title'); $title = $book->appendChild($title); $value = $doc->createTextNode($Item); $value = $title->appendChild($value); $quantity = $doc->createElement('quantity'); $quantity = $book->appendChild($quantity); $value2 = $doc->createTextNode($ItemName); $value2 = $quantity->appendChild($value2); } $strXml = $doc->saveXML(); return $strXml; } ?>