User Guide
184 Server-Side ActionScript Language Reference
Example
The following example creates a very simple XML object and outputs the result of a call to
getNamespaceForPrefix():
function createXML() {
var str = "<Outer xmlns:exu=\"http://www.example.com/util\">"
+ "<exu:Child id='1' />"
+ "<exu:Child id='2' />"
+ "<exu:Child id='3' />"
+ "</Outer>";
return new XML(str).firstChild;
}
var xml = createXML();
trace(xml.getNamespaceForPrefix("exu")); // output: http://www.example.com/
util
trace(xml.getNamespaceForPrefix("")); // output: null
See also
XML.getPrefixForNamespace()
XML.getPrefixForNamespace()
Availability
Flash Media Server 2.
Usage
my_xml.getPrefixForNamespace(nsURI)
Parameters
nsURI A String; the namespace URI for which the method returns the associated prefix.
Returns
A String; the prefix associated with the specified namespace.
Description
Method; returns the prefix that is associated with the specified namespace URI for the node.
To determine the prefix,
getPrefixForNamespace() searches up the XML hierarchy from
the node, as necessary, and returns the prefix of the first xmlns declaration with a namespace
URI that matches
nsURI.
If there is no xmlns assignment for the given URI, the method returns null. If there is an
xmlns assignment for the given URI but no prefix is associated with the assignment, the
method returns an empty string (
"").