SetName

Description

Sets the name of the current PBDOM_PROCESSINGINSTRUCTION object.

Note

Starting from Version 2022, the PBDOM_PROCESSINGINSTRUCTION object is no longer supported to add and modify the XML declarations, therefore, an exception will be thrown when SetName("xml") is executed. You can set the XML declaration through the PBDOM_DOCUMENT SetXMLDeclaration method instead of using SetName("xml").

Syntax

pbdom_pi_name.SetName(string strName)

Argument

Description

pbdom_pi_name

The name of a PBDOM_PROCESSINGINSTRUCTION object

strName

The new name you want to set for the current PBDOM_PROCESSINGINSTRUCTION object


Return value

Boolean.

Returns true if the name of the current PBDOM_PROCESSINGINSTRUCTION object was changed, and false otherwise.

Throws

EXCEPTION_INVALID_NAME -- This exception is thrown if the name is "xml". The PBDOM_PROCESSINGINSTRUCTION object is no longer supported to add and modify the XML declarations starting from Version 2022. You will have to use the PBDOM_DOCUMENT SetXMLDeclaration method to set the XML declaration, otherwise the EXCEPTION_INVALID_NAME exception will be thrown.

EXCEPTION_INVALID_STRING -- This exception is thrown if the name is xml and the current data of this PBDOM_PROCESSINGINSTRUCTION object is not valid. The data is valid only under the following circumstances:

  • It is an empty string.

  • If it is not an empty string, it must contain a name/value pair for the name version.

  • If it is not an empty string and it contains a name/value pair for the name version, it can also contain a name/value pair for the name encoding.

  • If it is not an empty string and it contains a name/value pair for the name version, it can also contain a name/value pair for the name standalone. If it does, the value for standalone must be either yes or no (both are case sensitive).

  • If it is not an empty string and it contains a name/value pair for the name version, it must not contain any other data (in name/value pair format or otherwise) except for encoding and standalone.

Usage

This method is equivalent to setting the target of the processing instruction object. See the list of exceptions for information about the restrictions on the use of xml as the target.