createProcessingInstruction (W3C DOM Core method)
var pi = document.createProcessingInstruction ('xml-stylesheet', 'type="text/xml" href="test.xsl"');
The end result of that operation would be this XML:
<?xml-stylesheet type="text/xml" href="test.xsl"?>
notice how there's a space between the name and the data, which is
required to separate them in static XML; and indeed, when we retrieve the
data property of a static
ProcessingInstruction node, that leading space is
included. However it's not necessary to include it in the
data argument of this method.
The XML Prolog at the top of an XML document is not a processing instruction, even though it looks like one.
The created processing instruction node.
says that this method should throw a
in HTML mode1 (code 9:
Therefore if a browser supports it and does not throw an exception in that
mode, this is considered a bug, and is what happens in
Opera and Safari 1.3 and
In Internet Explorer in HTML this method
is not implemented (it returns undefined). Similarly to the previous
note, this cannot be considered a bug or lack of support because
ProcessingInstruction is an XML construct.
1 On XHTML or HTML pages served as
There are no comments yet.