I am using SimpleXML to build a document, and wondering whether it is possible to insert comment tag to the document like this:
When using $root->asXML() you'd get a string like this:
You may notice it generated an empty element as well, but it's the price to pay. Don't try to add a value, it would only mess everything up. Use only in conjunction with asXML().
Well, I did say it's a dirty trick. I don't recommend using this in production, but only for debugging/testing purposes.