i’m using the DOMdocument class in php whenever i want to create a XML document.
but how could i open a XML document and add elements after an existing element in the XML document?
its a very huge XML-document so it would be great to consider the most efficient way to do this.
If you’re sticking with DOMdocument, appending a new node is as simple as getting a reference to an existing node, creating child nodes, and then appending new nodes to those children. I’ve used XPath below, but any method that returns a DOMNode should work. The important part to remember is even though you’ve fetched a part of the tree, internally it’s part of the original DOMDocument.