Hello W3S, I'm trying to use DOMDocument but when i use appendChild its not appending to the element I expect it to. Here is a simple example-
$DOM = new DOMDocument();$DOM->appendChild($DOM->createElement("div"));$DOM->appendChild($DOM->createElement("div"));$DOM->appendChild($DOM->createElement("div"));$DOM->appendChild($DOM->createElement("div"));echo $DOM->saveXML();
What I expect-
<body> <div></div> <div></div> <div></div> <div></div></body>
What I get-
<body> <div> <div> <div> <div> </div> </div> </div> </div></body>
I've looked at the PHP documentation and this looks like how they did it but obviously I'm missing something. Can anyone spot my mistake? Edit: Also, i need to use createElement because I want to manipulate the elements before adding them. When you use new DOMElement() its read only for whatever reason