data property
Gets the data of a processing instruction.
![]() ![]() |
Syntax
| JavaScript | |
|---|
Property values
Type: String
The name of the processing instruction.
Standards information
Remarks
Processing instructions are supported only by XML documents.
A processing instruction provides direction to an XML parser. The following code example shows a processing instruction that is specified in markup.
<?xml-stylesheet type="text/css" href="style.css"?>
For this example, the data property would return type='text/css' href='style.css'.
Examples
The following code example shows the relationship between the target and data properties of a processing instruction object.
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"> <html> <head> <title>IE9 DOMProcessingInstruction Sample</title> <meta name="x-ua-compatible" content="ie=9"> <script type="text/javascript"> function showInfo() { try { var oImp = document.implementation; var oDoc = oImp.createDocument( "", "", null ); // works var sTarget = "xml-stylesheet"; var sData = "type='text/css' href='style.css'"; var oPI = oDoc.createProcessingInstruction( sTarget, sData ); alert( oPI ); } catch( oErr ) { var sError = "Error " + oErr.code + ": " + oErr.message; alert( sError ); }; } </script> </head> <body> <button onclick="showInfo();">Click Me!</button> </body> </html>
See also
Show:

