function praseXML ()
{
for (var i = 0; i < myXML.firstChild.childNodes.length; i ++)
{
var tempObj = myXML.firstChild.childNodes[i].attributes;
myArray.push (
{
linkURL : tempObj.linkURL,
imgURL : tempObj.imgURL
})
}
ImageMax = myXML.firstChild.childNodes.length;
onHidden();
}xml文件如下
<?xml version="1.0" standalone="yes"?>
<ds>
  <Table>
    <linkURL>www.gofordesign.com</linkURL>
    <imgURL>01.jpg</imgURL>
  </Table>
  <Table>
    <linkURL>www.gofordesign.com</linkURL>
    <imgURL>u=3779555069,3378449312&amp;gp=30.jp</imgURL>
  </Table>
  <Table>
    <linkURL>www.gofordesign.com</linkURL>
    <imgURL>02.jpg</imgURL>
  </Table>
  <Table>
    <linkURL>www.gofordesign.com</linkURL>
    <imgURL>02.jpg</imgURL>
  </Table>
  <Table>
    <linkURL>www.gofordesign.com</linkURL>
    <imgURL>02.jpg</imgURL>
  </Table>
</ds>没有读到linkURL 和imgURl,

解决方案 »

  1.   

    这是我写的,LZ参考下
    //数组,存放从xml中读取的数据
    var arraystr:Array=new Array();//读取xml从中获取图片标题以及图片地址,以及链接地址
    var xmldoc:XML=new XML()
    xmldoc.ignoreWhite = true;
    xmldoc.onLoad=function(sucess)
    {
    if(sucess)
    {
    for(var i=0;i<xmldoc.firstChild.childNodes.length;i++)
    {
    var arrtmp:Array=new Array();
    arrtmp.push(xmldoc.firstChild.childNodes[i].attributes["title"]);
    arrtmp.push(xmldoc.firstChild.childNodes[i].attributes["imgpath"]);
    arrtmp.push(xmldoc.firstChild.childNodes[i].attributes["link"]);
    arraystr.push(arrtmp);
    }
    gotoAndPlay(2);
    }
    }
    xmldoc.load("flash/flashad.xml");这是名为flashad.xml的文件
    <?xml version="1.0" encoding="utf-8"?>
    <root>
    <item title="第一个" imgpath="1.jpg" link="http://baidu.com/1" />
    <item title="第二个" imgpath="3.jpg" link="http://baidu.com/2" />
    <item title="第三个" imgpath="6.jpg" link="http://baidu.com/3" />
    <item title="第四个" imgpath="7.jpg" link="http://baidu.com/4" />
    <item title="第五个" imgpath="9.jpg" link="http://baidu.com/5" />
    </root>我估计楼主是没有忽略空白元素,
    xmldoc.ignoreWhite = true;
    加上看看
      

  2.   

    我以前的xml也是这样写的,别人说格式不对,就改成上面这样的了,现在读不出来了,是不是这句有错啊,var tempObj = myXML.firstChild.childNodes[i].attributes,有人帮看看吗,谢谢
      

  3.   

    我目前这个用的很好,
    lz你 trace下myXML.firstChild.childNodes[i].attributes
    trace下myXML.firstChild.childNodes[i]就知道是那里的问题了,结贴吧