CakeFest 2017 NYC, the Official CakePHP Conference


(PHP 4 >= 4.1.0)

DomDocument->create_processing_instructionCreates new PI node


domprocessinginstruction DomDocument->create_processing_instruction ( string $content )

This function returns a new instance of class DomCData. The content of the pi is the value of the passed parameter. This node will not show up in the document unless it is inserted with (e.g.) domnode_append_child().

The return value is FALSE if an error occurred.

See also domnode_append_child(), domdocument_create_element(), domdocument_create_text(), domdocument_create_cdata_section(), domdocument_create_attribute(), domdocument_create_entity_reference(), and domnode_insert_before().

add a note add a note

User Contributed Notes 4 notes

fru at not dot spam dot com
12 years ago
note that
string DomDocument->
   create_processing_instruction ( string contenido)
takes two arguments:
- first: the processing instruction,
- second: the arguments and values of
      the processing instruction
:::so must be:
string DomDocument->
    create_processing_instruction ( string prInst,
           string contenido)
12 years ago
There's an error in both the above examples: it's "xml-stylesheet," not "xsl-stylesheet.Corrected examples:

    $pi = $dom->create_processing_instruction
      "type=\"text/xsl\" href=\"$stylesheet\""
apoco at cox dot net
13 years ago
That prior user example creates an invalid processing insruction under 4.3.4.  The first parameter is the processing instruction, and the second can be used for the attributes of the PI.   Here's a code snippet I used to insert a stylesheet:


= $doc->create_processing_instruction(
"type=\"text/xsl\" href=\"$stylesheet\"");

rj.kamp at hccnet dot nl
13 years ago
Please note that you have to use this function the following way to add a stylsheetr for client side processing.

$pi = $myDoc->create_processing_instruction('','xsl-stylesheet type="text/xsl" href="path_to_my_stylesheet"');


And note you have to add this to the document before the rootnode.
To Top