Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > VB Script

Vista - Convert Windows-1255 RSS to unicode, so I can call loadXML

Reply
 
Old 05-12-2009   #1 (permalink)
Gabriela


 
 

Convert Windows-1255 RSS to unicode, so I can call loadXML

Hi,
I have a short vbscript on an ASP page, and I want to perform loadXML
to this rss:
http://www.notes.co.il/rss.asp?b=7
Since it's encoded in Windows-1255, the loadXML fails.

I've tried using the conversion function here:
http://www.planet-source-code.com/vb...=7266&lngWId=4
Like this:

dim oXMLHTTP
set oXMLHTTP=Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
oXMLHTTP.open "GET", url , false
oXMLHTTP.send null

dim xmlDoc
Set xmlDoc=Server.CreateObject("MSXML2.DOMDocument.4.0")
xmlDoc.loadXML StrConv (oXMLHTTP.ResponseText,vbUnicode)

But it doesn't work.
Basically, the StrConv returns nothing.

Any ideas how I can get that RSS into the xmlDoc?

Thanks,
Gabi

My System SpecsSystem Spec
Old 05-13-2009   #2 (permalink)
Gabriela


 
 

Re: Convert Windows-1255 RSS to unicode, so I can call loadXML

On May 13, 2:34*am, Gabriela <frohlin...@xxxxxx> wrote:
Quote:

> Hi,
> I have a short vbscript on an ASP page, and I want to perform loadXML
> to this rss:http://www.notes.co.il/rss.asp?b=7
> Since it's encoded in Windows-1255, the loadXML fails.
>
> I've tried using the conversion function here:http://www.planet-source-code.com/vb...sp?txtCodeId=7...
> Like this:
>
> * * * * dim oXMLHTTP
> * * * * set oXMLHTTP=Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
> * * * * oXMLHTTP.open "GET", url , false
> * * * * oXMLHTTP.send null
>
> * * * * dim xmlDoc
> * * * * Set xmlDoc=Server.CreateObject("MSXML2.DOMDocument.4.0")
> * * * * xmlDoc.loadXML StrConv (oXMLHTTP.ResponseText,vbUnicode)
>
> But it doesn't work.
> Basically, the StrConv returns nothing.
>
> Any ideas how I can get that RSS into the xmlDoc?
>
> Thanks,
> Gabi
Correction - I'm using the conversion functions from these links:
StrConv(...): http://www.planet-source-code.com/UR...!4/anyname.htm
ANSIToUnicode(...): http://www.planet-source-code.com/vb...=7266&lngWId=4
Both return nothing.

Thanks again,
Gabi
My System SpecsSystem Spec
Old 05-14-2009   #3 (permalink)
ekkehard.horner


 
 

Re: Convert Windows-1255 RSS to unicode, so I can call loadXML

Gabriela schrieb:
Quote:

> Hi,
> I have a short vbscript on an ASP page, and I want to perform loadXML
> to this rss:
> http://www.notes.co.il/rss.asp?b=7
> Since it's encoded in Windows-1255, the loadXML fails.
>
> I've tried using the conversion function here:
> http://www.planet-source-code.com/vb...=7266&lngWId=4
> Like this:
>
> dim oXMLHTTP
> set oXMLHTTP=Server.CreateObject("MSXML2.ServerXMLHTTP.4.0")
> oXMLHTTP.open "GET", url , false
> oXMLHTTP.send null
>
> dim xmlDoc
> Set xmlDoc=Server.CreateObject("MSXML2.DOMDocument.4.0")
> xmlDoc.loadXML StrConv (oXMLHTTP.ResponseText,vbUnicode)
>
> But it doesn't work.
> Basically, the StrConv returns nothing.
>
> Any ideas how I can get that RSS into the xmlDoc?
>
> Thanks,
> Gabi
I *think* the problem is caused by MSXML2.(ServerOrNot)XMLHTTP having
difficulties with that encoding.

I used this test code:

''# getRssXml - get some rss as xml
' http://msdn.microsoft.com/en-us/libr...8VS.85%29.aspx
' ############################################################################

Option Explicit

Dim sURL : sURL = "http://www.notes.co.il/rss.asp?b=7"
Dim aGetters : aGetters = Array( "WinHttp.WinHttpRequest.5.1", "MSXML2.XMLHTTP" )
Dim sGetter
For Each sGetter In aGetters
WScript.Echo "Getter", sGetter
Dim oGetter : Set oGetter = CreateObject( sGetter )
Dim nErr, sErr

oGetter.open "GET", sURL, False
On Error Resume Next
oGetter.Send
nErr = Err.Number
sErr = Err.Description
On Error GoTo 0
If 0 = nErr Then
WScript.Echo oGetter.Status, oGetter.StatusText
Dim sRSS : sRSS = oGetter.responseText
WScript.Echo Left( sRSS, 45 )
Dim oXMLDOC : Set oXMLDOC = CreateObject( "MSXML2.DOMDocument" )
' sRSS = Left( sRSS, Len( sRSS ) - 10 ) ' if you want to see an parseError
Dim bOk : bOk = oXMLDOC.loadXML( sRSS )
If bOk Then
WScript.Echo "ok"
Else
WScript.Echo "not ok"
WScript.Echo oXMLDOC.parseError.reason
End If
Else
WScript.Echo "sGetter: Some Problems"
WScript.Echo nErr, sErr
End If
WScript.Echo "--------------------"
Next
WScript.Quit 0

output (e.g.):

cscript GetRssXml.vbs
Getter WinHttp.WinHttpRequest.5.1
200 OK
<?xml version="1.0" encoding="windows-1255"?>
ok
--------------------
Getter MSXML2.XMLHTTP
200 OK
<?xml version="1.0" encoding="windows-1255"?>
not ok
An invalid character was found in text content.

--------------------

on different W2K and XP computers - with different version of XMLHTTP
and DomDocument - and always had failures with the second getter. I must
admit, that I couldn't test it server side (.asp) - no server - and
that I don't know if the DomDoc tree is usable, but I *think* that using
WinHttpRequest.5.1 will give you a chance to solve your problem.
My System SpecsSystem Spec
Reply

Thread Tools


Similar Threads
Thread Forum
display unicode (utf-8) files in Windows Console PowerShell
Bulk Convert .TXT Files to Unicode VB Script
Call function with parameters that also call functions (.Net and P PowerShell
Windows Vista: How do I convert WMM files to .wmv? Vista music pictures video
convert pab to csv for import into windows mail Vista mail


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46