XML class
185
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() {
var str = "<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 = createXML();
trace(xmlDoc.getPrefixForNamespace("http://www.example.com/util")); //
output: exu
trace(xmlDoc.getPrefixForNamespace("http://www.example.com/other")); //
output: null
var child1 = xmlDoc.firstChild;
trace(child1.getPrefixForNamespace("http://www.example.com/child")); //
output: [empty string]
trace(child1.getPrefixForNamespace("http://www.example.com/other")); //
output: null
See also
XML.getNamespaceForPrefix()
Содержание FLASH MEDIA SERVER 2-SERVER-SIDE ACTIONSCRIPT...
Страница 1: ...Server Side ActionScript Language Reference...
Страница 4: ...4 Contents...
Страница 228: ...228 Server Side ActionScript Language Reference...
Страница 234: ...234 Server Side Information Objects...