dbTalk Databases Forums  

Import/Export XML and special characters

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Import/Export XML and special characters in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
denis
 
Posts: n/a

Default Import/Export XML and special characters - 10-17-2003 , 05:47 AM






Hi everybody

I'm using the following code to export a table to an XML

'************************************************* *********************
' Visual Basic ActiveX Script
'************************************************* ***********************
Function Main()
Dim oCmd, sSQL, oDom
Set oDom = CreateObject("Microsoft.XMLDOM")
Set oCmd = CreateObject("ADODB.Command")

oCmd.ActiveConnection =
"PROVIDER=SQLOLEDB;SERVER=sql.intra.net;UID=sa;PWD =login4sa;DATABASE=Chelab;
"
sSQL = "<ROOT xmlns:sql='urn:schemas-microsoft-com:xml-sql'><sql:query>"
& _
"select * from prova where ann_acc='11111' for xml auto,
elements </sql:query></ROOT>"
oCmd.CommandText = sSQL
oCmd.Dialect = "{5D531CB2-E6Ed-11D2-B252-00C04F681B71}"
oCmd.Properties("Output Stream") = oDom
oCmd.Execute , , 1024
oDom.Save "c:\denis.xml"
Main = DTSTaskExecResult_Success
End Function



Some of my fields have special characters like à,è,ì,ò,% etc.

The output XML is the following
<?xml version="1.0" ?>
<ROOT xmlns:sql="urn:schemas-microsoft-com:xml-sql">
<prova>
<ANN_ACC>11111</ANN_ACC>
<NUM_ACC>ààà</NUM_ACC>
</prova>
</ROOT>


No problems for the export but when I try to import the generated xml using
XMLBulkLoad an error occurs telling me that there are invalid characters.
The solution I've found is to manually change the first row of the xml to
<?xml version="1.0" encoding="iso-8859-1" ?>

I need to automatically specify the encoding during the export or during the
import (using XMLBulkLoad component)


Can you help me?
Thanks






Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.