Hinweis: Verwenden Sie die
Der zurückgegebene Klon ist nicht mehr mit der Struktur des geklonten Knotens verknüpft. Somit haben
Ist für dieses Präfix kein Namespace definiert, gibt die Methode
Wenn Sie einen leeren String (
Wenn keine
Bei XMLDocument-Objekten der obersten Ebene (mit dem Konstruktor erstellt) gibt die
Die in Flash Player integrierte XMLNode-Klasse unterstützt nur die Typen
var myColor:String = doc.firstChild.attributes.color
Für Textknoten ist diese Eigenschaft undefiniert (
Auf das Namespace-Präfix kann über die
Weist der XML-Knoten kein Präfix auf, hängt der Wert der Eigenschaft
Zum Ermitteln des Namespace für ein bestimmtes Präfix können Sie die
Die
Die XMLDocument-Klasse sowie „XMLNode“ und „XMLNodeType“ gibt es aus Gründen der Abwärtskompatibilität. Die Funktionen zum Laden von XML-Dokumenten finden Sie nun in der URLLoader-Klasse.
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:
Hinweis: Verwenden Sie die
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\">";
Der XML-Parser vorheriger Versionen von ActionScript ist kein validierender Parser. Die
Wenn bei der Analyse keine
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:
Betrachten Sie das folgende XMLDocument-Objekt:
In diesem Beispiel ist die
Sie müssen die
Sind mehrere XMLNode-Objekte mit dem gleichen
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:
Sie können die
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();