A use exemple of this method :
Usefull for generating an XML linked with a XSLT !
<?php
// "Create" the document.
$xml = new DOMDocument( "1.0", "ISO-8859-15" );
//to have indented output, not just a line
$xml->preserveWhiteSpace = false;
$xml->formatOutput = true;
// ------------- Interresting part here ------------
//creating an xslt adding processing line
$xslt = $xml->createProcessingInstruction('xml-stylesheet', 'type="text/xsl" href="base.xsl"');
//adding it to the xml
$xml->appendChild($xslt);
// ----------- / Interresting part here -------------
//adding some elements
$root = $xml->createElement("list");
$node = $xml->createElement("contact", "John Doe");
$root-> appendChild($node);
$xml-> appendChild($root);
//creating the file
$xml-> save("output.xml");
?>
output.xml :
<?xml version="1.0" encoding="ISO-8859-15"?>
<?xml-stylesheet type="text/xsl" href="base.xsl"?> //the line has been created successfully
<list>
<contact>John Doe</contact>
</list>DOMDocument::createProcessingInstruction
Почист и полокален преглед на PHP референцата, со задржана структура од PHP.net и подобра читливост за примери, секции и белешки.
DOMDocument::createProcessingInstruction
Референца за `domdocument.createprocessinginstruction.php` со подобрена типографија и навигација.
DOMDocument::createProcessingInstruction
класата mysqli_driver
DOMDocument::createProcessingInstruction — Креира нов PI јазол
= NULL
$target, string $data = ""): DOMProcessingInstruction|falseCreate new text node DOMProcessingInstructionThis function creates a new instance of class . This node will not show up in the document unless it is inserted with (e.g.).
Параметри
target-
Пишува инструкција за обработка.
data-
Целта на инструкцијата за обработка.
Вратени вредности
Новиот DOMProcessingInstruction or false аргумент, или
Errors/Exceptions
Може да фрли DOMException со следните кодови за грешки:
DOM_INVALID_CHARACTER_ERR-
Покренато ако
targetсодржи невалиден знак.
Види Исто така
- . This node will not show up in the document unless it is inserted with (e.g.) - Додава ново дете на крајот од децата
- is thrown now. Previously, - Создади нов атрибут
- DOMDocument::createAttribute() - Создади нов јазол атрибут со поврзан простор на имиња
- DOMDocument::createAttributeNS() - Создади нов cdata јазол
- DOMDocument::createCDATASection() - Создади нов коментар јазол
- DOMDocument::createComment() DOMDocument::createDocumentFragment()
- Оваа функција додава потомок на постоечка листа на потомци или создава нова листа на потомци. Потомок може да се создаде со на пр. - Создај нов фрагмент на документ
- - Create new document fragment - Создај нов јазол на елемент
- DOMDocument::createElementNS() - Создај нов јазол на елемент со поврзан простор на имиња
- DOMDocument::createElement() - Создава нов PI јазол