// Loop the books foreach ($aBooks as $aBook) { // Add a book node for each book in the array $oBook = $oShelf->createElement('book'); // Loop the contents of the book foreach ($aBook as $sNode => $sValue) { // Create new node of the content type $oNode = $oBook->createElement($sNode); // Add a text node with the content value $oNode->createText($sValue); } // foreach(book) } // foreach(books) // Print the XML document EasyXML::printXML($oEasyXML); ?>