XMLNode 1323
getPrefixForNamespace
(XMLNode.getPrefixForNamespace method)
public getPrefixForNamespace(nsURI:String) : String
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 (
""
).
Availability:
ActionScript 1.0; Flash Player 8
Parameters
nsURI
:String
- The namespace URI for which the method returns the associated prefix.
Returns
String
- The prefix associated with the specified namespace.
Example
The following example creates a very simple XML object and outputs the result of a call to the
getPrefixForNamespace()
method. The
Outer
XML node, which is represented by the
xmlDoc
variable, defines a namespace URI and assigns it to the
exu
prefix. Calling the
getPrefixForNamespace()
method with the defined namespace URI ("http://
www.example.com/util") returns the prefix
exu
, but calling this method with an undefined
URI ("http://www.example.com/other") returns
null
. The first
exu:Child
node, which is
represented by the
child1
variable, also defines a namespace URI ("http://
www.example.com/child"), but does not assign it to a prefix. Calling this method on the
defined, but unassigned, namespace URI returns an empty string.
function createXML():XMLNode {
var str:String = "<Outer xmlns:exu=\"http://www.example.com/util\">"
+ "<exu:Child id='1' xmlns=\"http://www.example.com/child\"/>"
+ "<exu:Child id='2' />"
+ "<exu:Child id='3' />"
+ "</Outer>";
return new XML(str).firstChild;
}
var xmlDoc:XMLNode = createXML();
Содержание FLASH 8-ACTIONSCRIPT 2.0 LANGUAGE
Страница 1: ...ActionScript 2 0 Language Reference ...
Страница 1352: ...1352 ActionScript classes ...