Connection Information

To perform the requested action, WordPress needs to access your web server. Please enter your FTP credentials to proceed. If you do not remember your credentials, you should contact your web host.

Connection Type

SetAttribute Syntax 2 – PB Docs 126 – PowerBuilder Library

SetAttribute Syntax 2 – PB Docs 126

PBDOM_ELEMENT:

SetAttribute Syntax 2 method

Description

Adds a PBDOM_ATTRIBUTE object and its value to a
PBDOM_ELEMENT object. Any existing attribute with the same
name and namespace URI is overwritten.

Syntax

Argument

Description

pbdom_element_name

The name of a PBDOM_ELEMENT
object

strName

The name of the PBDOM_ATTRIBUTE
to be added

strValue

The value of the PBDOM_ATTRIBUTE
to be added

Return Values

PBDOM_ELEMENT. The PBDOM_ELEMENT object
modified to contain the specified PBDOM_ATTRIBUTE with
the specified value.

Throws

EXCEPTION_INVALID_ARGUMENT – One
or both of the input strings are invalid. This can happen if either
or both strings have not been initialized properly or are null.

EXCEPTION_MEMORY_ALLOCATION_FAILURE – Insufficient
memory was encountered while executing this method.

EXCEPTION_PBDOM_OBJECT_INVALID_FOR_USE – This PBDOM_ELEMENT
object’s internal implementation is null.
The occurrence of this exception is rare but can take place if severe
memory corruption occurs.

EXCEPTION_INVALID_NAME – An
invalid name for the attribute is supplied.

EXCEPTION_INVALID_STRING – An
invalid string for the attribute value is supplied.

Examples

The SetAttribute method is invoked
for the following XML element:

The SetAttribute method is invoked from
the following PowerScript statement, where elem_code represents
the code element:

The following XML element results:

The following example demonstrates the effect of
setting an attribute for a PBDOM_ELEMENT object when the
PBDOM_ELEMENT object already contains an attribute of the
same name. The example creates a PBDOM_DOCUMENT based on
the following document:

The child1 element already contains an
attribute named b with value 456. Calling
the SetAttribute method with name b and
value 789 creates a new attribute for child1 that
replaces the original b attribute.

After the PBDOM_DOCUMENT object is saved and converted
to XML, the XML document looks like the following:

Usage

This method allows the caller to add an attribute/value
pair to a PBDOM_ELEMENT object. If the PBDOM_ELEMENT
object already contains an existing attribute that has the same
name as the input name and that belongs to no namespace, the original
attribute is removed from this PBDOM_ELEMENT object and
a new one (corresponding to the specified attribute name and value)
is created and set in its place.

If a PBDOM_ATTRIBUTE has been created to represent
the original attribute, it is still valid, but the attribute that
it represents has been detached from the original owner element.
Calling GetOwnerElementObject on this PBDOM_ATTRIBUTE
returns a null value.

See Also


Document get from Powerbuilder help
Thank you for watching.
Was this article helpful?
Subscribe
Notify of
guest
0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x