Christian Stocker wrote: <snip> </snip>
Thank you Christian, the following code worked fine.Use $dom->createProcessingInstruction($target, $data) ; and then append this to the document. that could maybe work see http://ch.php.net/manual/en/function.dom-domdocument-createprocessinginstruction.php for more details.
(From within the DOM object)
$this->preserveWhiteSpace = false;
$this->resolveExternals = true;
$styleSheet = $this->createProcessingInstruction("xml-stylesheet", "type='text/xsl' href='../../../course.xsl'");
$this->appendChild($styleSheet);
$this->createRoot();
$this->formatOutput = TRUE;
<snip>
</snip>
And the formatting is not lost. you didn't provide any ;) The DOM Extension doesn't make any assumptions about the formatting of your XML document (or correctly said, it doesn't insert whitespace "automagically" ) but you can try to set the property formatOutput just before saveXML:
$doc->formatOutput = true;
Never tested, but should work
I already had formatOutput = true; in the sample code. Of course when I am loading the DOM from a string, I am providing the formatting, which DOM is honouring but when I am creating the DOM completely from php, you are right, I am providing no formatting. In this case, the formatOutput works as I would have expected, (default??)formatted output when true, and not formatted when false. It would seem that if you provide some formatting, DOM expects you to provide it all. When I have finished this current assignment, I'll try to follow the calls through from PHP to libxml2, and see if I can find something more.
Once again, thanks for your help... Dusty
-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php