<?php
 if (isset($_POST['submitProduct']))
 {
     $xml = new DomDocument("1.0", "UTF-8");
     $xml->load('./data/productDB.xml');
     $productName = $_POST['productName'];
     $productDescription = $_POST['productDescription'];
     $quantity = $_POST['quantity'];
     $stock = $_POST['stock'];
     $price = $_POST['price'];
     $size = $_POST['size'];
     $type = $_POST['type'];
     $rootTag = $xml->getElementsByTagName("root")->item(0);
     $infoTag = $xml->createElement("info");
     $productNameTag = $xml->createElement("product-name", $productName);
     $productDescriptionTag = $xml->createElement("product-description", $productDescription);
     $quantityTag = $xml->createElement("quantity", $quantity);
     $stockTag = $xml->createElement("stock", $stock);
     $priceTag = $xml->createElement("price", $price);
 
     $infoTag->append($productNameTag);
     $infoTag->append($productDescriptionTag);
     $infoTag->append($quantityTag);
     $infoTag->append($stockTag);
     $infoTag->append($priceTag);
     $rootTag->append($infoTag);
     $xml->save("productDB.xml");
 }
?>
Here, I have $size and $type which are arrays. However, if I use the following method to add these array to the xml:
$sizeTag = $xml->createElement("size", $size);
I get the following error: Warning: DOMDocument::createElement() expects parameter 2 to be string, array given
How do you write arrays to xml? Does PHP have a built in method?
 
    