The ProcessingInstruction() constructor creates a new ProcessingInstruction object instance.
new ProcessingInstruction(target, data)targetA string representing the type of event.
dataA string containing any information the processing instruction should carry, after the target. The data is up to you, but it can't contain ?>, since that closes the processing instruction.
Processing instructions are, as the name suggests, are instructions about how to process the document. They can include stylesheets for XML documents, placeholders for HTML documents, or other processing instructions.
A new ProcessingInstruction object, if used internally by the browser.
Developers cannot use the ProcessingInstruction() constructor directly to create a new ProcessingInstruction instance, and must use the document.createProcessingInstruction() method instead. Attempting to use the ProcessingInstruction() constructor directly results in an "illegal constructor" error.
InvalidCharacterError DOMExceptionThrown if either of the following are true:
TypeErrorThrown with the message "Illegal constructor" when used directly.
const doc = new DOMParser().parseFromString("<foo />", "application/xml");
const pi = doc.createProcessingInstruction(
"xml-stylesheet",
'href="mycss.css"',
);