Parameter | Description |
---|---|
sNamespace | Namespace-URI string (e.g. http://dataaccess.com/MyURI) |
sBaseName | Name of attribute excluding the prefix |
Returns the text value of an attribute whose NamespaceURI and BaseName matches the passed values. Returns "" if no match is found.
Function AttributeValueNS string sNameSpace string sBaseName Returns String
Call: | Get AttributeValueNS sNameSpace sBaseName to StringVariable |
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
This message creates a node and a document that is namespace aware. This requires that you always pass a NameSpaceURI.