Condividi tramite


IElement.SetAttributeNS(String, String, String) Method

Definition

Adds a new attribute.

[Android.Runtime.Register("setAttributeNS", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "GetSetAttributeNS_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Handler:Org.W3c.Dom.IElementInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")]
public void SetAttributeNS (string? namespaceURI, string? qualifiedName, string? value);
[<Android.Runtime.Register("setAttributeNS", "(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V", "GetSetAttributeNS_Ljava_lang_String_Ljava_lang_String_Ljava_lang_String_Handler:Org.W3c.Dom.IElementInvoker, Mono.Android, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null")>]
abstract member SetAttributeNS : string * string * string -> unit

Parameters

namespaceURI
String

The namespace URI of the attribute to create or alter.

qualifiedName
String

The qualified name of the attribute to create or alter.

value
String

The value to set in string form.

Attributes

Exceptions

INVALID_CHARACTER_ERR: Raised if the specified qualified name is not an XML name according to the XML version in use specified in the Document.xmlVersion attribute.
NO_MODIFICATION_ALLOWED_ERR: Raised if this node is readonly.
NAMESPACE_ERR: Raised if the qualifiedName is malformed per the Namespaces in XML specification, if the qualifiedName has a prefix and the namespaceURI is null, if the qualifiedName has a prefix that is "xml" and the namespaceURI is different from "", if the qualifiedName or its prefix is "xmlns" and the namespaceURI is different from "", or if the namespaceURI is "" and neither the qualifiedName nor its prefix is "xmlns".
NOT_SUPPORTED_ERR: May be raised if the implementation does not support the feature "XML" and the language exposed through the Document does not support XML Namespaces (such as []).

Remarks

Adds a new attribute. If an attribute with the same local name and namespace URI is already present on the element, its prefix is changed to be the prefix part of the qualifiedName, and its value is changed to be the value parameter. This value is a simple string; it is not parsed as it is being set. So any markup (such as syntax to be recognized as an entity reference) is treated as literal text, and needs to be appropriately escaped by the implementation when it is written out. In order to assign an attribute value that contains entity references, the user must create an Attr node plus any Text and EntityReference nodes, build the appropriate subtree, and use setAttributeNodeNS or setAttributeNode to assign it as the value of an attribute. <br>Per [XML Namespaces] , applications must use the value null as the namespaceURI parameter for methods if they wish to have no namespace.

Added in DOM Level 2.

Java documentation for org.w3c.dom.Element.setAttributeNS(java.lang.String, java.lang.String, java.lang.String).

Portions of this page are modifications based on work created and shared by the Android Open Source Project and used according to terms described in the Creative Commons 2.5 Attribution License.

Applies to