RE: [PHP] Re: How to Insert <?xml-stylesheet .....?> into DOMDocument
| From: | Shanon Swafford | Date: | Sat, 06 Dec 2008 23:08:33 +0000 |
| Subject: | RE: [PHP] Re: How to Insert <?xml-stylesheet .....?> into DOMDocument | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-284245@lists.php.net to get a copy of this message | ||
>> 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