Flash解析XML而不加载外部文件(as2)
在我的flash中,套接字服务器返回了我需要解析的一些xml数据,但似乎启动XML对象的唯一方法是使用加载外部文件的XML.Load(),但是我的XML文件已经加载变成一个变量
跟踪(“raw:”+ msg); msgArea.htmlText + =“
更新远程播放器loc“; var playerLocXMLOb = new XML(msg); playerLocXMLOb.ignoreWhite = true;
迹(playerLocXMLOb.firstChild.firstChild.nodeValue);
这只是返回
raw: <ploc><x>348</x><y>468</y><uid>red</uid></ploc>
null
你知道我做错了什么吗? 或者是外部文件的唯一途径?
不,你做得对,我会尝试
trace(playerLocXMLOb.x);
AS使用XML有一些非常奇怪的事情,您可以通过将它视为成员变量来实际访问节点。 试一试,看看会发生什么。
不知道发生了什么问题,但这是我曾经解决的问题:
docXML = new XML(msg);
XMLDrop = docXML.childNodes;
XMLSubDrop = XMLDrop[0].childNodes;
_root.rem_x = (parseInt(XMLSubDrop[0].firstChild));
_root.rem_y = (parseInt(XMLSubDrop[1].firstChild));
_root.rem_name = (XMLSubDrop[2].firstChild);
firstChild.nodeValue
怎么firstChild.nodeValue
?
trace(playerLocXMLOb.firstChild.nodeValue);//should trace 438
链接地址: http://www.djcxy.com/p/17791.html
上一篇: Flash parsing XML without loading an external file (as2)
下一篇: Is there a way to determine if Flash has cached an object?