且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

RSS新闻源

更新时间:2023-11-27 19:46:28

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 (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>





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 the
client where you don''t know which MSXML version is installed but in an
ASP script on the server you should find out which MSXML version is
installed and use one. In particular there is a special server side
version 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 can
examine
xmlhttp.status
xmlhttp.statusText
xmlhttp.getAllResponseHeaders()
xmlDoc = xmlhttp.responseXML
and then here
xmlDoc.parseError.errorCode
xmlDoc.parseError.reason
}
catch (e) {
alert(e)



ASP脚本中的
警报?这不会起作用。

-


Martin Honnen
http://JavaScript.FAQTs.com/


我看到了那个网站。很混乱。是否可以测试

xmlhttp.responseXML?如果xmlDoc没有合适的属性,那么我们可以创建填充xmlDoc的代码吗?

" VK" &LT; SC ********** @ yahoo.com&GT;在消息中写道

news:11 ********************* @ g49g2000cwa.googlegro ups.com ...
I saw that site. Very confusing. Is it possible to test
xmlhttp.responseXML? If xmlDoc doesn''t have the proper properties,
could we create code that would populate xmlDoc?
"VK" <sc**********@yahoo.com> wrote in message
news: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>