I am coding a lightweight controller that outputs XML. I'm currently trialling the DOMDocument object and using its saveXML() method. Only problem is that I want the XML inserted as a segment in the main XML file. But, the saveXML() includes <?xml version="1.0"?> on the first line and I don't want it. I also don't want to do something like: $doc = new DOMDocument('1.0'); // add stuff to $dom, possibly resulting in a very large document $xml = $doc->saveXML(); $xml = substr($xml, strpos($xml, "\n")); // or... substr($doc->saveXML(), strpos($doc->saveXML(), "\n")); PHP: Anyone got any ideas to do this? Preferably without requiring extra server load... Thanks in advance
$doc = new DOMDocument("1.0"); $xml = $doc->saveXML( ); $xml = substr( $xml, strpos( $xml, "\n") ); PHP: That works and is less server load the saving the xml twice
Yes, I don't know why I included the alternative But I'm trying to figure out a way to do this without doing either of those, not that I seem to have much choice.