Примечание. Пользуйтесь методами
Клон возвращаемого узла более не связан с деревом клонированного элемента. Следовательно,
Если область имен не определена ля указанного префикса, метод возвращает значение
Если в качестве
Если для данного URI не задан
При работе с объектами XMLDocument верхнего уровня (созданными с помощью конструктора) метод
Встроенный в программу Flash Player класс XMLNode поддерживает только значения
var myColor:String = doc.firstChild.attributes.color
Данное свойство не определено для текстовых узлов (
Префикс области имен доступен через свойство
Если у узла XML нет префикса, значение свойства
Можно использовать метод
Свойство
Класс XMLDocument, как и XMLNode и XMLNodeType, является обратно совместимым. Функциональность для загрузки XML-документов теперь содержится в классе 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:
Примечание. Пользуйтесь методами
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\">";
Синтаксический анализатор XML, встречающийся в предыдущих версиях ActionScript, не проверяет достоверность документа. Объявление
Если в ходе разбора не удается обнаружить объявление
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:
Рассмотрим следующий объект XMLDocument:
В данном примере свойство
Для создания экземпляра свойства
Если объектов XMLNode с одинаковым значением
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:
Можно назначить свойство
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();