You cannot add document nodes (result of parseFromString ). Instead, take the child of the document and add it:
var parser = new DOMParser(); var newNode = parser.parseFromString(newCategory, "text/xml"); stack.appendChild(newNode.documentElement);
Please note that your HTML is not XML-complient, so you may get errors parsing it. In this case, make sure that you correct them (for example, the duplicated attribute alt , ).
However, in your case, I doubt that you need to parse the XML at all. You can simply add the entire HTML line first. For example, for example:
var stack = document.getElementById('newCategories'); stack.insertAdjacentHTML('beforeend', newCategory);
source share