Skip to content

CreateAttributeNodeNS - cXMLDOMElement

Creates an namespace aware attribute and returns its object handle

Type: Function
Return Data Type: Handle

Parameters

Parameter Type Description
sNameSpace String the element NamespaceURI
sName String the name of the attribute including a prefix
sValue String the value of the attribute

Syntax

Function CreateAttributeNodeNS String sNameSpace String sName String sValue Returns Handle

Call Example

Get CreateAttributeNodeNS sNameSpace sName sValue to HandleVariable

Description

CreateAttributeNodeNS creates an attribute node. This function creates an XML node but does not add it to an XML element. An attribute node can be created and appended in a single step using the AddAttributeNS message.

If successful, the function returns an object handle for the newly created node. If zero is returned, the operation failed. If a node is returned, it is your responsibility to eventually destroy the object (e.g. Send Destroy of hoMyCreatedNode).

Col 1 Col 2
Note: All XML objects created using any of the CreateXxxxx methods will create the DataFlex object as a child of the main document node (the cXmlDomDocumentObject). The actual hierarchy of your XML document has nothing to do with this object placement. The messages AppendNode, InsertBeforeNode and CloneNode determine placement of an XML node object within the document, where the object receiving the message will become the parent node.

Attributes and Namespaces

This message creates a node and a document that is namespace aware. This requires that you always pass a NameSpaceURI. Attributes are less likely to use namespaces (i.e., they are more likely to use the global namespace).Attributes never use the default namespace (xmlns="xx"). If the attribute does not have a prefix, it is in the global namespace.If a namespace is used, a prefix must be supplied. A prefix is supplied by adding the prefix to the sName (e.g., sName="m:table"). If your document does not have any namespaces or an element within the document does not have a namespace, its namespace is considered to be global and its NamespaceURI is represented as an empty string (""). In such a case you can and should use these namespace aware messages passing an empty string for the NameSpaceURI.

See Also

AddAttributeNS | AddElementNS(send) | AddElementNS(get) | CreateDocumentElementNS | CreateElementNodeNS

Return Value

If successful, the function returns an object handle for the newly created attribute node.