03.05.2013 Views

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

ActionScript 2.0 Language Reference - Adobe Help and Support

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Example<br />

The following example creates a very simple XML object <strong>and</strong> outputs the result of a call to the<br />

getPrefixForNamespace() method. The Outer XML node, which is represented by the<br />

xmlDoc variable, defines a namespace URI <strong>and</strong> assigns it to the exu prefix. Calling the<br />

getPrefixForNamespace() method with the defined namespace URI ("http://<br />

www.example.com/util") returns the prefix exu, but calling this method with an undefined<br />

URI ("http://www.example.com/other") returns null. The first exu:Child node, which is<br />

represented by the child1 variable, also defines a namespace URI ("http://<br />

www.example.com/child"), but does not assign it to a prefix. Calling this method on the<br />

defined, but unassigned, namespace URI returns an empty string.<br />

function createXML():XMLNode {<br />

var str:String = ""<br />

+ ""<br />

+ ""<br />

+ ""<br />

+ "";<br />

return new XML(str).firstChild;<br />

}<br />

var xmlDoc:XMLNode = createXML();<br />

trace(xmlDoc.getPrefixForNamespace("http://www.example.com/util")); //<br />

output: exu<br />

trace(xmlDoc.getPrefixForNamespace("http://www.example.com/other")); //<br />

output: null<br />

var child1:XMLNode = xmlDoc.firstChild;<br />

trace(child1.getPrefixForNamespace("http://www.example.com/child")); //<br />

output: [empty string]<br />

trace(child1.getPrefixForNamespace("http://www.example.com/other")); //<br />

output: null<br />

See also<br />

getNamespaceForPrefix (XMLNode.getNamespaceForPrefix method), namespaceURI<br />

(XMLNode.namespaceURI property)<br />

XMLNode 1345

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!