VBScript中尝试读取RSS提要具有系统的问题,不支持指定的编码 [英] vbscript tries to read RSS feeds have issue of System does not support the specified encoding

查看:795
本文介绍了VBScript中尝试读取RSS提要具有系统的问题,不支持指定的编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图用一个客户端的URL来显示我们的网站供稿。 ,我遇到的问题是,它似乎他们的应用程序是用Java编写的,而XML响应的编码为ISO8859_1,这不是由MSXML的Active X对象支持的编码。请参阅此链接,以供参考: http://support.microsoft。 COM / Default.aspx的SCID = KB; EN-US; q304625

问题是,我很怀疑,我将能够改变,甚至要求更改响应XML的编码。是否有其他变通方法呢?

code

 功能GetXmlDom(金银丝)
        设置GetXmlDom =的Server.CreateObject(MSXML2.DOMDocument)
        GetXmlDom.async = FALSE
        GetXmlDom.setPropertyServerHTT prequest,真
        GetXmlDom.load(金银丝)结束功能

它首先会显示所有这似乎罚款头。然后我得到这个错误:

错误code 1072896658原因系统不支持指定的编码。
系统错误:-1072896658

如果我浏览到我的浏览器相同的URL,它显示了XML文档的罚款。

您可以请建议对同一个解决方案

谢谢,
罗希特


解决方案

  

我很怀疑,我将能够改变,甚至要求更改响应XML的编码。


嗯,这是坏了。 的IANA说,对于ISO-8859-1的规范名称是 ISO-8859-1 。而ISO8859_1不是它一个合法的别名。要养成良好的网络公民,你的的要求的变化。指出,这是破了,并要求修复。要养成良好的公民,你的客户应该修复这个bug。

ISO8859_1是最初使用,我认为,Java库code之内,因为这映射到ISO-8859-1的名称命名。这种用法是很好,但我不明白的映射的需要。但是,从那里的人认为内部名称Java使用实际上是编码名称 - 不正确的。这实在是只知道Java的一个别名。然后是错误的观念,小号$ P $垫到Java之外的其他库和框架的假设正确,如果Java是用ISO8859_1作为编码名称,它必须是正确的。底线是ISO8859_1不应在一个IANA编码串预计实际XML文档中使用。


在此期间...


  

如果我浏览到我的浏览器相同的URL,它显示了XML文档的罚款。


这不是我所得到的。使用此作为RSS源:

 <?XML版本=1.0编码=ISO8859_1&GT?;
< RSS版本=2.0>
  <渠道>
<标题> FeedForAll样品饲料和LT; /标题>
<描述> RSS是一种极具吸引力的技术。 ....< /描述>
 ...

我得到这样的结果在IE8:

要在VBScript读它,你需要更换 ISO8859_1 ISO-8859-1 。这是使用ServerHTT prequest对象pretty容易。

 功能UrlGet(URL)
    设置XMLHTTP =的CreateObject(MSXML2.ServerXMLHTTP.6.0)
    xmlhttp.openGET,网址,假
    xmlhttp.send
    ''对待输出为纯文本。我们知道它可能被打破。
    UrlGet = xmlhttp.responseText
结束功能
昏暗的网址
URL =HTTP://localhost/misc/broken.rss'上述网址的XML声明开始
''< XML版本=1.0编码=ISO8859_1&GT?;
''...这是无效的,因为ISO8859_1不是有效的
'XML编码的名字。昏暗urlText
urlText = UrlGet(URL)''替换我们认为它应该是编码
urlText =替换(urlText,编码=ISO8859_1,,编码=ISO-8859-1)设置DOC1 =的CreateObject(Msxml2.DOMDocument.6.0)
doc1.async =假
DOC1。preserveWhiteSpace =假'真
doc1.loadXml(urlText)

I am trying to use a client's URL to shows feeds on our site. The problem that I am having is that it appears that their application was written in java, and the encoding of the XML response is ISO8859_1, an encoding which is not supported by the MSXML active x object. Please see this link for reference: http://support.microsoft.com/default.aspx?scid=kb;EN-US;q304625.

The problem is, I highly doubt that I will be able to change, or even request to change the encoding of the response xml. Is there another work around for this?

CODE

Function GetXmlDom(pUrl)
        Set GetXmlDom = Server.CreateObject("MSXML2.DOMDocument")
        GetXmlDom.async = False
        GetXmlDom.setProperty "ServerHTTPRequest", True
        GetXmlDom.load(pUrl)

End Function

It will first display all of the headers which seem fine. Then i get this error:

error code 1072896658 Reason System does not support the specified encoding. System error: -1072896658.

If i navigate to the same URL in my browser, it displays the XML document fine.

Can you please suggest a solution for same

Thanks, Rohit

解决方案

I highly doubt that I will be able to change, or even request to change the encoding of the response xml.

Well, it's broken. The IANA says that the canonical name for ISO-8859-1 is ISO-8859-1. and ISO8859_1 is not a legal alias for it. To practice good internet citizenship, you should request the change. Point out that it's broken, and ask for a fix. To practice good citizenship, your client should fix that bug.

ISO8859_1 is a name that was originally used, I think, within Java library code, as a name that mapped to ISO-8859-1. This usage was fine, although I don't understand the need for the mapping. But from there people assumed that the internal name Java uses is actually the encoding name - not true. It is really an alias known only to Java. And then that erroneous belief spread to other libraries and frameworks outside of Java that assumed incorrectly that if Java was using ISO8859_1 as an encoding name, it must be right. The bottom line is that ISO8859_1 should not be used in actual xml documents where an IANA encoding string is expected.


In the meantime...

If i navigate to the same URL in my browser, it displays the XML document fine.

That's not what I get. Using this as the rss source:

<?xml version="1.0" encoding="ISO8859_1"?>
<rss version="2.0">
  <channel>
<title>FeedForAll Sample Feed</title>
<description>RSS is a fascinating technology. ....</description>
 ...

I get this result in IE8:

To read it in vbscript, you need to replace that ISO8859_1 with ISO-8859-1 . This is pretty easy using the ServerHTTPRequest object.

Function UrlGet(url)
    Set xmlhttp = CreateObject("MSXML2.ServerXMLHTTP.6.0")
    xmlhttp.open "GET", url, False
    xmlhttp.send
    '' treat the output as plain text. We know it may be broken.
    UrlGet = xmlhttp.responseText
End Function


Dim url
url = "http://localhost/misc/broken.rss"

'' the above URL starts with an XML declaration of
''    <?xml version="1.0" encoding="ISO8859_1"?>
'' ... which is invalid, because ISO8859_1 is not a valid
'' name for an XML encoding.

Dim urlText
urlText = UrlGet(url)

'' replace the encoding with what we think it should be
urlText = Replace(urlText,"encoding=""ISO8859_1""","encoding=""ISO-8859-1""")

Set doc1 = CreateObject("Msxml2.DOMDocument.6.0")
doc1.async = False
doc1.preserveWhiteSpace= False ' True
doc1.loadXml(urlText)

这篇关于VBScript中尝试读取RSS提要具有系统的问题,不支持指定的编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆