Remarque : utilisez les méthodes
Le clone du nœud qui est renvoyé n’est plus associé à l’arborescence de l’élément cloné. Par conséquent,
Si aucun espace de noms n’est défini pour ledit préfixe, la méthode renvoie
Si vous spécifiez une chaîne vide (
Si aucune affectation
Pour les objets XMLDocument de niveau supérieur (ceux créés avec le constructeur), la méthode
Dans Flash Player, la classe XMLNode intégrée prend uniquement en charge
var myColor:String = doc.firstChild.attributes.color
Cette propriété n’est pas définie pour les nœuds de texte (
Vous pouvez accéder au préfixe d’espace de noms par l’intermédiaire de la propriété
Si le nœud XML n’a pas de préfixe, la valeur de la propriété
Vous pouvez utiliser la méthode
La propriété
La classe XMLDocument, de même que XMLNode et XMLNodeType, a été conservée à des fins de compatibilité ascendante. La fonctionnalité permettant de charger des documents XML fait maintenant partie de la classe URLLoader.
The following example creates an XML object by parsing the XML text specified in the source
parameter, and populates the newly created XML object with the resulting XML document tree:
Remarque : utilisez les méthodes
createElement()
method:
createTextNode()
method, and places them into existing XML nodes:
XML.docTypeDecl
property to set the DOCTYPE
declaration for an XML object:
my_xml
.docTypeDecl = "<!DOCTYPE greeting SYSTEM \"hello.dtd\">";
L’ancien programme d’analyse XML ActionScript n’est pas un programme d’analyse de validation. La déclaration
En cas d’absence de déclaration
Then create a SWF file in the same directory as the XML file. Include the following script in the SWF:
When you test the SWF file, the following output is generated:
Considérez l’objet XMLDocument suivant :
Dans cet exemple, la propriété
Vous devez utiliser la méthode
Si plusieurs objets XMLNode ont la même valeur
foyer
tag comprises fourteen space characters. To run this example, create a text file named flooring.xml, and copy the following tags into it:
Create a new Flash document named flooring.fla and save it to the same directory as the XML file. Place the following code into the main Timeline:
If you then change the setting of flooring.ignoreWhite
to false
, or simply remove that line of code entirely, the fourteen space characters in the foyer
tag will be preserved:
The XML_blogTracker.fla and XML_languagePicker.fla files in the ActionScript samples folder also contain a code example. The following are typical paths to this folder:
Vous pouvez définir la propriété
my_txt
that has the same dimensions as the Stage. The text field displays properties of the XML packet that loads into the SWF file. The doc type declaration displays in my_txt
. Add the following ActionScript to your FLA or AS file:
var my_fmt:TextFormat = new TextFormat();
my_fmt.font = "_typewriter";
my_fmt.size = 12;
my_fmt.leftMargin = 10;
this.createTextField("my_txt", this.getNextHighestDepth(), 0, 0, Stage.width, Stage.height);
my_txt.border = true;
my_txt.multiline = true;
my_txt.wordWrap = true;
my_txt.setNewTextFormat(my_fmt);
var my_xml:XML = new XML();
my_xml.ignoreWhite = true;
my_xml.onLoad = function(success:Boolean) {
var endTime:Number = getTimer();
var elapsedTime:Number = endTime-startTime;
if (success) {
my_txt.text = "xmlDecl:"+newline+my_xml.xmlDecl+newline+newline;
my_txt.text += "contentType:"+newline+my_xml.contentType+newline+newline;
my_txt.text += "docTypeDecl:"+newline+my_xml.docTypeDecl+newline+newline;
my_txt.text += "packet:"+newline+my_xml.toString()+newline+newline;
} else {
my_txt.text = "Unable to load remote XML."+newline+newline;
}
my_txt.text += "loaded in: "+elapsedTime+" ms.";
};
my_xml.load("http://www.helpexamples.com/crossdomain.xml");
var startTime:Number = getTimer();