Description
Sets the raw data for the PBDOM_PROCESSINGINSTRUCTION object.
Syntax
pbdom_pi_name.SetData(string strData)
Argument |
Description |
---|---|
pbdom_pi_name |
The name of a PBDOM_PROCESSINGINSTRUCTION object |
strData |
New data for the PBDOM_PROCESSINGINSTRUCTION object |
Return value
PBDOM_PROCESSINGINSTRUCTION. The PBDOM_PROCESSINGINSTRUCTION object modified with the new data.
Throws
EXCEPTION_INVALID_STRING -- The input data is invalid. This can happen in the following circumstances:
-
The input data contains the sub-string "?>". This violates the requirements for the data of a processing instruction.
-
If the processing instruction target name is xml, making this PBDOM_PROCESSINGINSTRUCTION object an XML declaration processing instruction, this exception is thrown if the input data string does not conform to the following criteria:
-
The data must contain a name/value pair for the name version.
-
The data can contain a name/value pair for the name encoding.
-
The data can contain a name/value pair for the name standalone. If it does, the value for standalone must either be yes or no.
-
The data must not contain any other data in the form of name/value pairs or in any other form.
-
Lowercase
The strings xml, version, encoding, standalone, yes, and no are all case sensitive and must be in lowercase.
Examples
Suppose there is a PBDOM_PROCESSINGINSTRUCTION object as follows:
<?xml-stylesheet href="simple-ie5.xsl" type="text/xsl" ?>
Then, SetData("href=new.xsl") results in the PBDOM_PROCESSINGINSTRUCTION object being transformed into the following:
<?xml-stylesheet href=new.xsl" ?>
The entire data for the PBDOM_PROCESSINGINSTRUCTION object is now reset.
Usage
Special processing is performed when the name of the processing instruction's target is xml, which indicates that it is an XML declaration. The valid instructions allowed in the input Data as part of the name in the name/value pairs are version, encoding, and standalone. The version instruction is mandatory before the processing instruction can be added to a document.
The XML specification expects the instructions to be in the specific order version , encoding , standalone. This function reorders the input data to conform to the specification, for example:
<? xml version="1.0" encoding="utf-8" standalone="yes"?>