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 |