I have an application that retrieves XML from some web service written in PHP and inserts it into a SQL Server database. When I try to paste the resulting XML, which contains Polish diacritical characters, I get this error:
XML parsing: line 2, character 703, illegal xml character
I tried to do something like this:
DECLARE @xml XML; SET @xml = '(here I paste some sample XML that contains diacritical characters)'; SELECT @xml = CAST(@xmlstr AS XML); INSERT INTO vos_DirectXML_ut(ValidXML,synchronization_time,synchronization_type,MethodName) VALUES(@xml,GETDATE(),@SynchroType,@method);
ValidXML is an XML type column.
I found googled to find some solution, and found Utf8String: http://msdn.microsoft.com/en-us/library/ms160893(v=sql.90).aspx
I installed it and tried to convert XML to Utf8String, and then convert it to regular varchar again, and then to XML and paste into my table, but it looks like it does not change any characters inside this XML, it just changes the type of the variable and does not solve my problem.
I also found a couple of tips on how to solve a similar problem by writing a procedure that goes through a loop for each character in a variable (XML in my case) and manually changes its encoding, but this guy also said that it can work slow. Is this really the only way to solve my problem?
source share