getNamespaceForPrefix (XMLNode.getNamespaceForPrefix method)

public getNamespaceForPrefix(prefix:String) : String

Returns the namespace URI that is associated with the specified prefix for the node. To determine the URI, getPrefixForNamespace() searches up the XML hierarchy from the node, as necessary, and returns the namespace URI of the first xmlns declaration for the given prefix.

If no namespace is defined for the specified prefix, the method returns null.

If you specify an empty string ("") as the prefix and there is a default namespace defined for the node (as in xmlns="http://www.example.com/"), the method returns that default namespace URI.

Availability: ActionScript 1.0; Flash Player 8

Parameters

prefix:String - The prefix for which the method returns the associated namespace.

Returns

String - The namespace that is associated with the specified prefix.

Example

The following example creates a very simple XML object and outputs the result of a call to getNamespaceForPrefix()

function createXML():XMLNode {
    var str:String = "<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:XMLNode = createXML();
trace(xml.getNamespaceForPrefix("exu")); // output: http://www.example.com/util
trace(xml.getNamespaceForPrefix("")); // output: null

See also

getPrefixForNamespace (XMLNode.getPrefixForNamespace method), namespaceURI (XMLNode.namespaceURI property)


Flash CS3


 

Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/flash/9.0/main/00002350.html