本文介绍了RSS新闻源的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 29岁程序员,3月因学历无情被辞! 您好。我写了一个简单的asp脚本来阅读各种rss新闻源。我得到了一个新闻源,但是,回来时出现运行时错误[''null''是 null或者不是对象]。这是代码,被提炼到 错误: // 函数xml_load(src){ 尝试{ var xmlDoc = new ActiveXObject(" Microsoft.XMLDOM") var xmlhttp = new ActiveXObject(" Microsoft.XMLHTTP" ;) xmlhttp.open(" GET",src,false) xmlhttp.send() xmlDoc = xmlhttp.responseXML } catch(e){ alert(e) 返回null } 返回xmlDoc } // 函数xml_start(){ var xmlDoc = xml_load(" http://stardate.org/feeds/rss.xml") if(typeof(xmlDoc)!=" object")return'''' var root = xmlDoc.documentElement if(typeof(root)!=" object")return'''' if( typeof(root.childNodes)!=" object")返回''''//这里炸弹 } 我不知所措。你怎么能有一个没有childNodes的xmlDoc对象? 这个文件有什么问题 http://stardate.org/feeds/rss.xml ?没有编码声明?任何建议都将受到赞赏...丹尼斯Hi. I wrote a simple asp script to read various rss newsfeeds. I gotone newsfeed, however, that comes back with a runtime error [''null'' isnull or not an object]. Here''s the code, distilled to the point oferror://function xml_load(src) {try {var xmlDoc = new ActiveXObject("Microsoft.XMLDOM")var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")xmlhttp.open("GET",src,false)xmlhttp.send()xmlDoc = xmlhttp.responseXML}catch (e) {alert(e)return null}return xmlDoc}//function xml_start() {var xmlDoc = xml_load("http://stardate.org/feeds/rss.xml")if (typeof(xmlDoc) != "object") return ''''var root = xmlDoc.documentElementif (typeof(root) != "object") return ''''if (typeof(root.childNodes) != "object") return '''' // bombs here}I''m at a loss. How can you have a xmlDoc object having no childNodes?Is there something wrong with the file http://stardate.org/feeds/rss.xml? No encode statement? Any advice would be appreciated...Dennis推荐答案 Dennis Allen写道:Dennis Allen wrote:嗨。我写了一个简单的asp脚本来阅读各种rss新闻源。我得到了一个新闻源,然而,回来时出现运行时错误[''null''是 null或不是对象]。这里的代码被提炼到错误点: // 函数xml_load(src){尝试{ var xmlDoc = new ActiveXObject(" Microsoft.XMLDOM") var xmlhttp = new ActiveXObject(" Microsoft.XMLHTTP") xmlhttp.open(" GET",src,false) xmlhttp .send() xmlDoc = xmlhttp.responseXML } catch(e){提醒(e)返回null } 返回xmlDoc } // 函数xml_start(){ var xmlDoc = xml_load(" http://stardate.org/feeds/rss.xml") if(typeof(xmlDoc)!=" object")return'''' var root = xmlDoc.documentElement if(typeof(root)!=" object")return'' '' if(typeof(root.childNodes)!=" object")返回''''//这里炸弹} 我不知所措。如何让xmlDoc对象没有childNodes?文件是否有问题 http://stardate.org/feeds/rss.xml ?没有编码声明?任何建议将不胜感激... Dennis Hi. I wrote a simple asp script to read various rss newsfeeds. I got one newsfeed, however, that comes back with a runtime error [''null'' is null or not an object]. Here''s the code, distilled to the point of error: // function xml_load(src) { try { var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") xmlhttp.open("GET",src,false) xmlhttp.send() xmlDoc = xmlhttp.responseXML } catch (e) { alert(e) return null } return xmlDoc } // function xml_start() { var xmlDoc = xml_load("http://stardate.org/feeds/rss.xml") if (typeof(xmlDoc) != "object") return '''' var root = xmlDoc.documentElement if (typeof(root) != "object") return '''' if (typeof(root.childNodes) != "object") return '''' // bombs here } I''m at a loss. How can you have a xmlDoc object having no childNodes? Is there something wrong with the file http://stardate.org/feeds/rss.xml ? No encode statement? Any advice would be appreciated...Dennis 首先猜测stargate.org的管理员没有为XML设置MIME (''文/ XML '')。因此,XMLDOM无法使用responseXML(但是 自然XMLDOM作为对象仍然存在)。 因为XML / XLT服务仍然是(仍然!)一个相当新的bist,更多 安全不要指望服务器管理员,但使用MSXML解析器 responseText,在这里你不会哀号。 所有时间获胜者链接: < http://support.microsoft.com/Default.aspx?id = 893659>As the first guess the stargate.org''s admin did not set MIME for XML(''text/xml''). As the result responseXML cannot be used by XMLDOM (butnaturally XMLDOM as object still exists).As XML/XLT serving remains (still!) a rather new bist, it is moresecure do not count on server admins but use MSXML parser forresponseText, here you will not wail.The all times winner link:<http://support.microsoft.com/Default.aspx?id=893659> Dennis Allen写道:Dennis Allen wrote:嗨。我写了一个简单的asp脚本来阅读各种rss新闻源。我得到了一个新闻源,然而,回来时出现运行时错误[''null''是 null或不是对象]。这里的代码被提炼到错误点: // 函数xml_load(src){尝试{ var xmlDoc = new ActiveXObject(" Microsoft.XMLDOM") var xmlhttp = new ActiveXObject(" Microsoft.XMLHTTP") 这些(例如Microsoft.XMLHTTP)是程序ID在你不知道安装了哪个MSXML版本但在服务器上的一个 ASP脚本中你应该找出哪个MSXML版本的 客户端是有意义的 安装并使用一个。特别是有一个特殊的服务器端 版本的XMLHTTP,例如for MSXML 4 Msxml2.ServerXMLHTTP.4.0。 xmlhttp.open(" GET",src,false) xmlhttp.send() 为了分别找出发生了什么问题你可以 检查 xmlhttp.status xmlhttp.statusText xmlhttp.getAllResponseHeaders() xmlDoc = xmlhttp.responseXML 然后在这里 xmlDoc.parseError.errorCode xmlDoc.parseError.reason } catch(e){ alert(e) Hi. I wrote a simple asp script to read various rss newsfeeds. I got one newsfeed, however, that comes back with a runtime error [''null'' is null or not an object]. Here''s the code, distilled to the point of error: // function xml_load(src) { try { var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP")These (e.g. Microsoft.XMLHTTP) are program ids that make sense on theclient where you don''t know which MSXML version is installed but in anASP script on the server you should find out which MSXML version isinstalled and use one. In particular there is a special server sideversion of XMLHTTP, e.g. for MSXML 4 Msxml2.ServerXMLHTTP.4.0. xmlhttp.open("GET",src,false) xmlhttp.send()To find out what is happening respectively what is going wrong you canexaminexmlhttp.statusxmlhttp.statusTextxmlhttp.getAllResponseHeaders() xmlDoc = xmlhttp.responseXMLand then herexmlDoc.parseError.errorCodexmlDoc.parseError.reason } catch (e) { alert(e) ASP脚本中的警报?这不会起作用。 - Martin Honnen http://JavaScript.FAQTs.com/我看到了那个网站。很混乱。是否可以测试 xmlhttp.responseXML?如果xmlDoc没有合适的属性,那么我们可以创建填充xmlDoc的代码吗? " VK" < SC ********** @ yahoo.com>在消息中写道 news:11 ********************* @ g49g2000cwa.googlegro ups.com ...I saw that site. Very confusing. Is it possible to testxmlhttp.responseXML? If xmlDoc doesn''t have the proper properties,could we create code that would populate xmlDoc?"VK" <sc**********@yahoo.com> wrote in messagenews:11*********************@g49g2000cwa.googlegro ups.com... Dennis Allen写道: Dennis Allen wrote:嗨。我写了一个简单的asp脚本来阅读各种rss新闻源。然而,我得到了一个新闻源,它带来了运行时错误[''null''是 null或不是对象]。这里的代码被提炼到错误点: // 函数xml_load(src){尝试{ var xmlDoc = new ActiveXObject(" Microsoft.XMLDOM") var xmlhttp = new ActiveXObject(" Microsoft.XMLHTTP") xmlhttp.open(" GET",src,false) xmlhttp .send() xmlDoc = xmlhttp.responseXML } catch(e){提醒(e)返回null } 返回xmlDoc } // 函数xml_start(){ var xmlDoc = xml_load(" http://stardate.org/feeds/rss.xml") if(typeof(xmlDoc)!=" object")return'''' var root = xmlDoc.documentElement if(typeof(root)!=" object")return'' '' if(typeof(root.childNodes)!=" object")返回''''//这里炸弹} 我不知所措。如何让xmlDoc对象没有 childNodes?文件是否有问题 http://stardate.org/feeds/rss.xml ?没有编码声明?任何建议将不胜感激...丹尼斯 Hi. I wrote a simple asp script to read various rss newsfeeds. I got one newsfeed, however, that comes back with a runtime error [''null'' is null or not an object]. Here''s the code, distilled to the point of error: // function xml_load(src) { try { var xmlDoc = new ActiveXObject("Microsoft.XMLDOM") var xmlhttp = new ActiveXObject("Microsoft.XMLHTTP") xmlhttp.open("GET",src,false) xmlhttp.send() xmlDoc = xmlhttp.responseXML } catch (e) { alert(e) return null } return xmlDoc } // function xml_start() { var xmlDoc = xml_load("http://stardate.org/feeds/rss.xml") if (typeof(xmlDoc) != "object") return '''' var root = xmlDoc.documentElement if (typeof(root) != "object") return '''' if (typeof(root.childNodes) != "object") return '''' // bombs here } I''m at a loss. How can you have a xmlDoc object having no childNodes? Is there something wrong with the file http://stardate.org/feeds/rss.xml ? No encode statement? Any advice would be appreciated...Dennis 首先猜测stargate.org的管理员没有为XML设置MIME (''text / xml' )。因此,XMLDOM无法使用responseXML(但自然XMLDOM作为对象仍然存在)。因为XML / XLT服务仍然是(仍然!)一个相当新的bist,它更安全不要指望服务器管理员,而是使用MSXML解析器来回复 responseText,在这里你不会哀号。所有时间的赢家链接:< http://support.microsoft.com/Default .aspx?id = 893659> As the first guess the stargate.org''s admin did not set MIME for XML (''text/xml''). As the result responseXML cannot be used by XMLDOM (but naturally XMLDOM as object still exists). As XML/XLT serving remains (still!) a rather new bist, it is more secure do not count on server admins but use MSXML parser for responseText, here you will not wail. The all times winner link: <http://support.microsoft.com/Default.aspx?id=893659> 这篇关于RSS新闻源的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持! 上岸,阿里云! 06-21 14:49