AttributeValueNS - cXMLDOMElement
Returns the value of an atttribute node whose NamespaceURI and BaseName matches the passed values
Type: Function
Return Data Type: String
Parameters
| Parameter | Type | Description |
|---|---|---|
| sNameSpace | String | |
| sBaseName | String | Name of attribute excluding the prefix |
Syntax
Function AttributeValueNS String sNameSpace String sBaseName Returns String
Call Example
Get AttributeValueNS sNameSpace sBaseName to StringVariable
Description
AttributeValueNS is used to get the attribute value in an element node that matches the passed NamespaceURI and BaseName.
Assume you have the following Xml document
<Customer xmlns:m="http://www.dataaccess.com/Test/CustomerList" xmlns:x="SomeOtherURI">
<Name x:cnum="12">3A Software</Name>
</Customer>
The NamespaceURI for all of these elements is "http://www.dataaccess.com/Test/CustomerList". Because the attribute cnum has an explicit prefix defined, it has a NamespaceURI of "SomeOtherURI". We could search for the attribute value as follows:
Move "http://www.dataaccess.com/Test/CustomerList" to sNS // the namespace
Move "SomeOtherURI" to sNS2
Get DocumentElement of hoXML to hoRoot
// we need to get the element value and an attribute value from "Name". So we get its node
Get ChildElementNS of hoRoot sNS "Name" to hoName
Get AttributeValueNS of hoName sNS2 "cnum" to sNumber
Send Destroy of hoName
Assume you have the following Xml document
<Customer xmlns="http://www.dataaccess.com/Test/CustomerList">
<Name cnum="12">3A Software</Name>
</Customer>
The NamespaceURI for all of these elements is "http://www.dataaccess.com/Test/CustomerList". However, since attributes do not use default namespaces, the NamespaceURI for the attribute cnum is "". We could search for the attribute value as follows:
Move "http://www.dataaccess.com/Test/CustomerList" to sNS // the namespace
Get DocumentElement of hoXML to hoRoot
// we need to get the element value and an attribute value from "Name". So we get its node
Get ChildElementNS of hoRoot sNS "Name" to hoName
Get AttributeValueNS of hoName "" "cnum" to sNumber
Send Destroy of hoName
When there is no namespace we can use the AttributeValue message get the value.
Get AttributeValue of hoName "cnum" to sNumber
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 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 use these namespace aware messages passing an empty string for the NameSpaceURI.When parsing XML documents with namespaces you should always search by NamespaceURI and BaseName. You should not use the element's prefix and you should not attempt to ignore the NamespaceURI.
See Also
AttributeValue | AddAttributeNS | AttributeValueNodeNS
Return Value
Returns the text value of an attribute whose NamespaceURI and BaseName matches the passed values. Returns "" if no match is found.