在ActionScript中的XML对象中加载Blogger页面会导致缺少标记

时间:2021-11-26 06:44:04

Whenever I load any blogger page through an XML object in actionscript 2 almost all of the contents of the page magically disappear. I would assume that since the pages are in xhtml that this should work. Here is what I get if I try to load Steve Yegge's blog:

每当我通过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>

Scroll to the end and you can see that the entire <body> tag is missing. Any suggestions on how to fix this?

滚动到最后,您可以看到缺少整个标记。对于如何解决这个问题,有任何的建议吗?

Edit: Here is some quick code so you can test it yourself:

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

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

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

1 个解决方案

#1


Well, on quick inspection it looks like your page isn't living up to it's doctype, which is what is probably causing the problem. In general it doesn't look like it's valid XML, which is why ActionScript is choking on it. I just did a quick test with another XHTML strict page that does validate and I was able to scrape through the full node structure without a problem.

好吧,快速检查看起来你的页面没有达到它的doctype,这可能是导致问题的原因。一般来说,它看起来不像是有效的XML,这就是ActionScript窒息的原因。我刚刚使用另一个XHTML严格页面进行了快速测试,该页面确实进行了验证,并且我能够毫无问题地完成整个节点结构。

If you can't fix the markup, you may want to look into the onData event of the AS2 XML class - it lets you grab the raw data prior to parsing. That may let you pull out the content you need in a different manner.

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

#1


Well, on quick inspection it looks like your page isn't living up to it's doctype, which is what is probably causing the problem. In general it doesn't look like it's valid XML, which is why ActionScript is choking on it. I just did a quick test with another XHTML strict page that does validate and I was able to scrape through the full node structure without a problem.

好吧,快速检查看起来你的页面没有达到它的doctype,这可能是导致问题的原因。一般来说,它看起来不像是有效的XML,这就是ActionScript窒息的原因。我刚刚使用另一个XHTML严格页面进行了快速测试,该页面确实进行了验证,并且我能够毫无问题地完成整个节点结构。

If you can't fix the markup, you may want to look into the onData event of the AS2 XML class - it lets you grab the raw data prior to parsing. That may let you pull out the content you need in a different manner.

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