Форум 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 является ElementNode, а когда T (http://www.flasher.ru/forum/showthread.php?t=115157)

wvxvw 20.08.2008 19:19

Как отличить, когда строка переданая конструктору XML является ElementNode, а когда T
 
Ну, желательно, чтобы самому не парсить =)
Кстати, не уверен, но по-моему раньше так не было...
Вот тест:
(почему во втором случае hasChildNodes() == true, nodeType == 1 для меня загадка)
Код:

var xml:XML = new XML('<Slide />');
trace(xml.hasChildNodes());
trace(xml.nodeType);
trace(xml.childNodes[0]);
for(var i:String in xml)
{
        trace(i+" => "+xml[i]);
}
trace("-----------");
xml = new XML('foo');
trace(xml.hasChildNodes());
trace(xml.nodeType);
trace(xml.childNodes[0]);
for(i in xml)
{
        trace(i+" => "+xml[i]);
}

Output:
Код:

true
1
<Slide />
namespaceURI => null
localName => null
prefix => null
previousSibling => null
parentNode => null
nodeValue => null
nodeType => 1
nodeName => null
nextSibling => null
lastChild => <Slide />
firstChild => <Slide />
childNodes => <Slide />
attributes => undefined
getPrefixForNamespace => [type Function]
getNamespaceForPrefix => [type Function]
toString => [type Function]
hasChildNodes => [type Function]
appendChild => [type Function]
insertBefore => [type Function]
removeNode => [type Function]
cloneNode => [type Function]
xmlDecl => undefined
status => 0
loaded => undefined
ignoreWhite => false
docTypeDecl => undefined
contentType => application/x-www-form-urlencoded
addRequestHeader => [type Function]
getBytesTotal => [type Function]
getBytesLoaded => [type Function]
onData => [type Function]
onLoad => [type Function]
sendAndLoad => [type Function]
send => [type Function]
load => [type Function]
parseXML => [type Function]
createTextNode => [type Function]
createElement => [type Function]
-----------
true
1
foo
namespaceURI => null
localName => null
prefix => null
previousSibling => null
parentNode => null
nodeValue => null
nodeType => 1
nodeName => null
nextSibling => null
lastChild => foo
firstChild => foo
childNodes => foo
attributes => undefined
getPrefixForNamespace => [type Function]
getNamespaceForPrefix => [type Function]
toString => [type Function]
hasChildNodes => [type Function]
appendChild => [type Function]
insertBefore => [type Function]
removeNode => [type Function]
cloneNode => [type Function]
xmlDecl => undefined
status => 0
loaded => undefined
ignoreWhite => false
docTypeDecl => undefined
contentType => application/x-www-form-urlencoded
addRequestHeader => [type Function]
getBytesTotal => [type Function]
getBytesLoaded => [type Function]
onData => [type Function]
onLoad => [type Function]
sendAndLoad => [type Function]
send => [type Function]
load => [type Function]
parseXML => [type Function]
createTextNode => [type Function]
createElement => [type Function]


MrPoma 20.08.2008 19:24

Код:

var xml:XML = new XML('foo');
trace(xml.firstChild);
trace(xml.firstChild.hasChildNodes());
trace(xml.firstChild.nodeType);


wvxvw 20.08.2008 19:30

во млин... странно... спасибо =)

etc 20.08.2008 19:33

Гы:
Код:

function testTextNode(xml) {
        return xml.firstChild.nodeValue != xml.nodeName;
}
trace(testTextNode(new XML('<Slide />')));
trace(testTextNode(new XML('foo')));



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

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