[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
?
Solved

German "Umlaute" in MSXML

Posted on 2008-11-11
11
Medium Priority
?
1,533 Views
Last Modified: 2013-11-25
If I load the xml from http://www.consolewars.de/headlines.rss to the MSXML DOM, I get an error of an invalid charachter in this line/item:

<title>CapcomStore eröffnet am Donnerstag</title>

Problem is the german "Umlaut" ö within the title. How can I prevent the MSXML parser to throw out this error or what can I do that the parser will load the xml correctly?
0
Comment
Question by:Sven
  • 7
  • 4
11 Comments
 
LVL 30

Expert Comment

by:Olaf Doschke
ID: 22931427
At the begin of the xml a codepage might be encoded. This should be some codepage containing german characters. I don't know what parser you use, it might take UTF-8 as default, where the ö character would be invalid.
0
 
LVL 11

Author Comment

by:Sven
ID: 22931468
Here is my code so far. XMLRequest is a function of my own that works without error. It's only loading the xml source via MSXML2.ServerXMLHTTP.
Set objXML = CreateObject("MSXML2.DOMDocument.6.0")
 
With objXML
 
        .async = False
        .resolveExternals = False
        .validateOnParse = False
        .setProperty "ProhibitDTD", False	
         
         strXML = XMLRequest("http://www.consolewars.de/headlines.rss")
   
        .loadXML strXML 
 
End With
 
Set objXML = Nothing

Open in new window

0
 
LVL 11

Author Comment

by:Sven
ID: 22931484
@Olaf: As state I use the MSXML parser (MSXML2.DOMDocument.6.0). Codepage within windows is UTF-16 I think.
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 30

Expert Comment

by:Olaf Doschke
ID: 22931493
Sorry, you already said you are using MSXML DOM, I see the XML is encoded with encoding="ISO-8859-1" (Latin-1), which would be sufficient for german chars and that of several other languages. The MSXML parser seems not to respect that.
Bye, Olaf.
 
0
 
LVL 30

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 400 total points
ID: 22931772
I think the "error" is that loading the xml into a variable with strXML = XMLRequest(http://www.consolewars.de/headlines.rss) makes this an UTF-16 string, so LoadXML will not accept the now invalid ö.
See here: http://msdn.microsoft.com/en-us/library/aa468560.aspx
quote:
The bottom line is that you cannot switch between a multibyte character set like UTF-8, Shift-JIS, or Windows-1250 and Unicode character encodings such as UTF-16, UCS-2, or UCS-4 using the encoding attribute on an XML declaration, because the declaration itself has to use the same number of bytes per character as the rest of the document.
So as strXML is UTF-16 the parser cannot switch to ISO-8859-1. Perhaps loading the xml to the DOM object directly might help.
Bye, Olaf.
 
0
 
LVL 30

Expert Comment

by:Olaf Doschke
ID: 22933085
that is of course...
...
.loadXML XMLRequest("http://www.consolewars.de/headlines.rss")
...

Open in new window

0
 
LVL 30

Assisted Solution

by:Olaf Doschke
Olaf Doschke earned 400 total points
ID: 22933178
or how about:
objXML = CreateObject("MSXML2.DOMDocument.6.0")
objxml.load("http://www.consolewars.de/headlines.rss")
strXML = objxml.xml

Open in new window

0
 
LVL 11

Author Comment

by:Sven
ID: 22937500
Mmh... allready tried that witout success (code below). Problem is, that the ressource seems not to be loaded but the parser does return true on load-Method !?
Dim objXML
 
Set objXML = CreateObject("MSXML2.DOMDocument.6.0")
 
If objXML.load("http://www.consolewars.de/headlines.rss") Then
 
	Response.ContentType = "text/xml"
	Response.Write objXML.xml
 
Else
 
	Response.Write objXML.parseError.reason & "[Line: " & objXML.parseError.line & ", Pos: " & objXML.parseError.linepos & "]"
	
End If
 
Set objXML = Nothing

Open in new window

0
 
LVL 30

Expert Comment

by:Olaf Doschke
ID: 22937871
So you say this will run the If branch, as load returns true, but you don't get anythoung out of objxml.xml? You should again set objXML.async=False, like in your first sample, before load. Otherwise you write objXML.xml before anything is loaded.

Bye, Olaf.
0
 
LVL 11

Accepted Solution

by:
Sven earned 0 total points
ID: 22937898
Hi Olaf, the only way I got it to work right now is using this code (see below). I now got to see if the characters are all correct when getting the items but for the moment I got the xml into the MSXML DomDocument and can parse it.
<%
Dim objXMLHTTP, objXML
 
Set objXMLHTTP = Server.CreateObject("MSXML2.ServerXMLHTTP.3.0")
 
objXMLHTTP.open "GET", "http://www.consolewars.de/headlines.rss", True
objXMLHTTP.send 
objXMLHTTP.waitForResponse 3
 
Set objXML = Server.CreateObject("MSXML2.DOMDocument.6.0")
 
objXML.async = False
objXML.resolveExternals = False
objXML.validateOnParse = False
 
If objXML.load(objXMLHTTP.responseStream) Then
	
	If objXML.validate Then
 
		Response.ContentType = "text/xml"
		Response.Write objXML.xml
	
	Else
 
		Response.Write objXML.parseError.reason & "[Line: " & objXML.parseError.line & ", Pos: " & objXML.parseError.linepos & "]"
	
	End If	
		
 
Else
 
	Response.Write objXML.parseError.reason & "[Line: " & objXML.parseError.line & ", Pos: " & objXML.parseError.linepos & "]"
	
End If
 
Set objXML = Nothing
Set objXMLHTTP = Nothing
%>

Open in new window

0
 
LVL 30

Expert Comment

by:Olaf Doschke
ID: 22937957
Hm, as you set validateonparse = False, checking objXML.validate seems rather useless, it would always be true, wouldn't it? Anyway, glad you got it working.

Bye, Olaf.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This demonstration started out as a follow up to some recently posted questions on the subject of logging in: http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/Q_28634665.html and http://www.experts-exchange.com/Programming/…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

830 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question