MACROMEDIA FLASH MEDIA SERVER 2-SERVER MANAGEMENT ACTIONSCRIPT LANGUAGE Manual do Utilizador Página 137

  • Descarregar
  • Adicionar aos meus manuais
  • Imprimir
  • Página
    / 155
  • Índice
  • MARCADORES
  • Avaliado. / 5. Com base em avaliações de clientes
Vista de página 136
ADOBE FLASH MEDIA INTERACTIVE SERVER
Server-Side ActionScript Language Reference
134
Example
The following example creates an element node and a text node, and checks the node name of each:
// Create an XML document.
var doc = new XML();
// Create an XML node by using createElement().
var myNode = doc.createElement("rootNode");
// Place the new node into the XML tree.
doc.appendChild(myNode);
// Create an XML text node by using createTextNode().
var myTextNode = doc.createTextNode("textNode");
// Place the new node into the XML tree.
myNode.appendChild(myTextNode);
trace(myNode.nodeName);
trace(myTextNode.nodeName);
/*
output:
rootNode
null
*/
The following example creates a new XML packet. If the root node has child nodes, the code loops over each child
node to display the name and value of the node. Add the following ActionScript to your ASC file:
var my_xml = new
XML("<login><username>hank</username><password>rudolph</password></login>");
if (my_xml.firstChild.hasChildNodes()) {
// Use firstChild to iterate through the child nodes of rootNode.
for (var aNode = my_xml.firstChild.firstChild; aNode != null; aNode=aNode.nextSibling) {
if (aNode.nodeType == 1) {
trace(aNode.nodeName+":\t"+aNode.firstChild.nodeValue);
}
}
}
The following node names appear:
username:hank
password:rudolph
XML.nodeType
my_xml.nodeType
Read-only; a nodeType value, either 1 for an XML element or 3 for a text node.
The
nodeType property is a numeric value from the NodeType enumeration in the W3C DOM Level 1 Recommen-
dation. The following table lists the values:
Vista de página 136
1 2 ... 132 133 134 135 136 137 138 139 140 141 142 ... 154 155

Comentários a estes Manuais

Sem comentários