PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
My current solution is to use substr(). I would try and use DOMDocumentFragment but it doesn't have any functionality for converting it back to a string.
If I want to process HTML and echo it in the middle of an HTML document. If you use the loadHTML() type methods it's even worse because it adds a doctype as well.
As an option, you could load your XML as you currently are and do a simple XSL transform on it (using an xsl:copy to output the exact format as the source XML) and set your xsl:output to use the omit-xml-declaration attribute: <xsl:output method = "xml" omit-xml-declaration = "yes" />
It's a few more lines of code, but will do what you need to do.