Форум Flasher.ru

Форум Flasher.ru (http://www.flasher.ru/forum/index.php)
-   ActionScript 3.0 (http://www.flasher.ru/forum/forumdisplay.php?f=83)
-   -   nodeValues return null (http://www.flasher.ru/forum/showthread.php?t=114744)

Nata_cher 07.08.2008 17:40

nodeValues return null
 
есть хмл документ
Код:

<?xml version="1.0" encoding="windows-1251"?>
<root>
        <Menu1>
                <Name>Horizontal level</Name>
                <SubMenu>Assembly of the device1</SubMenu>
                <SubMenu>Mount the location fixture before the last head part1</SubMenu>
                <SubMenu>At last mount the head part1</SubMenu>
        </Menu1>
        <Menu2>
                <Name>Vertical level</Name>
                <SubMenu>Assembly of the device2</SubMenu>
                <SubMenu>Mount the location fixture before the last head part2</SubMenu>
                <SubMenu>At last mount the head part2</SubMenu>
        </Menu2>
</root>

при парсинге
Код:

        public class ParseXml {
                trace("ParseXml");
                private var xDoc:XMLDocument;
                private var xmlString:URLRequest = new URLRequest("xml/menu.xml");
                private var xmlLoader:URLLoader = new URLLoader(xmlString);

                function ParseXml() {
                        xmlLoader.addEventListener("complete", init);
                }
                function init(event:Event):void {
                        var xDoc:XMLDocument = new XMLDocument();
                        xDoc.ignoreWhite = true;
                        var menuXML:XML = XML(xmlLoader.data);
                        xDoc.parseXML(menuXML.toXMLString());
                        trace(xDoc.firstChild.childNodes[0].childNodes[0]);
                }
                public function xmlDocument():XMLDocument {
                        return xDoc;
                }
        }

в трейсере
Код:

trace(xDoc.firstChild.childNodes[0].childNodes[0]);
выводит
Код:

<Name>Horizontal level</Name>
но если
Код:

trace(xDoc.firstChild.childNodes[0].childNodes[0]).nodeValue);
возвращает null.
Как получить Horizontal level?

Kamchatka 07.08.2008 17:47

для начала написать
Код:

trace(xDoc.firstChild.childNodes[0].childNodes[0].nodeValue);
может поможет)

Nata_cher 07.08.2008 17:53

вопрос решился
Код:

trace(xDoc.firstChild.childNodes[0].childNodes[0].childNodes[0]);

etc 07.08.2008 23:25

А чем вам XML-то не угодил? Привычка со времен AS1/AS2?


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

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