0

每当我通过 actionscript 2 中的 XML 对象加载任何博客页面时,页面的几乎所有内容都会神奇地消失。我会假设因为这些页面是在 xhtml 中的,所以这应该可以工作。如果我尝试加载 Steve Yegge 的博客,我会得到以下结果:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml" xmlns:b="http://www.google.com/2005/gml/b" xmlns:data="http://www.google.com/2005/gml/data" xmlns:expr="http://www.google.com/2005/gml/expr"><head><script type="text/javascript">(function() { var a=window;function f(e){this.t={};this.tick=function(d,b,c){var i=c?c:(new Date).getTime();this.t[d]=[i,b]};this.tick(&quot;start&quot;,null,e)}var g=new f;a.jstiming={Timer:f,load:g};try{a.jstiming.pt=a.external.pageT}catch(h){};a.tickAboveFold=function(e){var d,b=e,c=0;if(b.offsetParent){do c+=b.offsetTop;while(b=b.offsetParent)}d=c;d</script></head></html>

滚动到最后,您可以看到整个<body>标签都丢失了。对于如何解决这个问题,有任何的建议吗?

编辑: 这是一些快速代码,因此您可以自己测试:

var foo:XML = new XML();
foo.ignoreWhite = true;

foo.onLoad = function(success:Boolean) {
    trace(foo.toString());
}
foo.load("http://steve-yegge.blogspot.com/");
4

1 回答 1

1

好吧,经过快速检查,您的页面似乎没有达到它的文档类型,这可能是导致问题的原因。一般来说,它看起来不像是有效的 XML,这就是 ActionScript 对它感到窒息的原因。我刚刚对另一个 XHTML 严格页面进行了快速测试,该页面确实进行了验证,并且我能够毫无问题地浏览完整的节点结构。

如果您无法修复标记,您可能需要查看 AS2 XML 类的 onData 事件 - 它可以让您在解析之前获取原始数据。这可能会让你以不同的方式提取你需要的内容。

于 2009-07-21T14:12:16.033 回答