Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 1.0/2.0 (http://www.flasher.ru/forum/forumdisplay.php?f=93)
-   -   XML и flash (доступ к дереву) (http://www.flasher.ru/forum/showthread.php?t=102852)

Snut 24.10.2007 14:13

XML и flash (доступ к дереву)
 
Есть XML вида:
Код:

<?xml version="1.0" encoding="utf-8"?>
<texts>
<part title="Some title">
<![CDATA[Some text]]>
</part>
<part title="Some title">
<![CDATA[Some text]]>
</part>
</texts>

гружу его вот так:
Код:

my_xml = new XML()
my_xml.load("site.xml")
my_xml.onLoad=function(success) {
        if(!success || this.status){
                  return this.customErrorHandler(this.status, success)
        }
        this.customParsingProcedure()
}
my_xml.customParsingProcedure = function (){
        trace("XML loaded"); // говорит что лоадед
        _root.link_to_node = _root.my_xml.firstChild;
        trace(_root.link_to_node.attributes.name) // выводит undefined
}
my_xml.customErrorHandler = function (status, success){
trace("loaded: " + success +" valid: " + !this.status)
        trace('XML not loaded');
}

помогите добраться до нодов и имен атрибутов пожалуйста..
соответственно для атрибута в 1 ноде title1=Some title, и text1=Some text
чет ничего не получается...

Fernando Costa 24.10.2007 14:33

а где в твоем XML аттрибут name? я вижу только аттрибут title

Snut 24.10.2007 14:49

Fernando Costa, по утру еще и не такое бывает, проблема решена. но вот незадача...

грузим так:
Код:

my_xml = new XML()
my_xml.ignoreWhite = true;
var url:String = "site.xml";
my_xml.load(url);
my_xml.onLoad=function(success) {
        if(!success || this.status){
                  return this.customErrorHandler(this.status, success)
        }
        this.customParsingProcedure()
}
my_xml.customParsingProcedure = function (){
        trace("XML loaded");
        trace("XML Status: "+my_xml.status);
        _root.link_to_node = _root.my_xml;
        _root.link_to_node = _root.link_to_node.firstChild.firstChild;
        title1 = _root.link_to_node.attributes.title;
        text1 = _root.link_to_node.firstChild;
        _root.link_to_node = _root.link_to_node.nextSibling;
        title2 = _root.link_to_node.attributes.title;
        text2 = _root.link_to_node.firstChild;
        _root.link_to_node = _root.link_to_node.nextSibling;
        title3 = _root.link_to_node.attributes.title;
        text3 = _root.link_to_node.firstChild;
        _root.link_to_node = _root.link_to_node.nextSibling;
        title4 = _root.link_to_node.attributes.title;
        text4 = _root.link_to_node.firstChild;
        _root.link_to_node = _root.link_to_node.nextSibling;
        title5 = _root.link_to_node.attributes.title;
        text5 = _root.link_to_node.firstChild;
}
my_xml.customErrorHandler = function (status, success){
trace("loaded: " + success +" valid: " + !this.status)
        trace('XML not loaded');
}

далее заполнение динамических текстовых полей:
Код:

this.main_tf_mc1.main_tf.htmlText = text1;
this.title_tf_mc1.title_tf.htmlText = title1;

однако html теги в тексте отображаются "as is" например <p align="left"> и т.д.
всем полям поставлена галока Render text as HTML.
вот понять и не могу... че он н хочет теги кушать...

Snut 24.10.2007 15:07

Проблема решена:
text1 = _root.link_to_node.firstChild;
меняем на
text1 = _root.link_to_node.firstChild.nodeValue;

эх.... учиться и учиться мне еще..


Часовой пояс GMT +4, время: 21:41.

Copyright © 1999-2008 Flasher.ru. All rights reserved.
Работает на vBulletin®. Copyright ©2000 - 2026, Jelsoft Enterprises Ltd. Перевод: zCarot
Администрация сайта не несёт ответственности за любую предоставленную посетителями информацию. Подробнее см. Правила.