RE: Re: How to Insert <?xml-stylesheet .....?> into DOMDocument

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



>> Is there a way to make it create the following XML?
>> 
>> <?xml version="1.0"?>
>> <?xml-stylesheet href="xsl_table.xsl" type="text/xsl"?>
>> <foo>
>>   <bar/>
>>   <bazz/>
>> </foo>
>> 
>> I can't seem to find any dom functions to do this.
>> 
>> Thanks in advance,
>> Shanon
>> 
>> 
>
>DOMProcessingInstruction as such:
>
><?php
>error_reporting(E_ALL | E_STRICT);
>
>$doc = new DOMDocument();
>$doc->formatOutput = true;
>
>// processing instruction data
>$styleheetParams = 'href="xsl_table.xsl" type="text/xsl"';
>
>// create processing instruction
>$xmlstylesheet = new DOMProcessingInstruction( 'xml-stylesheet',
$styleheetParams);
>
>//append it to the doc
>$doc->appendChild($xmlstylesheet);
>
>$foo = $doc->createElement("foo");
>$doc->appendChild($foo);
>
>$bar = $doc->createElement("bar");
>$foo->appendChild($bar);
>
>$bazz = $doc->createElement("bazz");
>$foo->appendChild($bazz);
>
>echo $doc->saveXML();
>
>?>

Thanks Nathan,

That worked perfect!

Shanon



-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux