0
我必须编写一个脚本,将字符串从sql_latin1_general_cp1_ci_as中的MSSQL服务器数据库转换为XML文件中使用UTF8编码的值。 有没有人有想法如何在VBS中做?将sql_latin1_general_cp1_ci_as字符串转换为utf8使用VBS
谢谢!
我必须编写一个脚本,将字符串从sql_latin1_general_cp1_ci_as中的MSSQL服务器数据库转换为XML文件中使用UTF8编码的值。 有没有人有想法如何在VBS中做?将sql_latin1_general_cp1_ci_as字符串转换为utf8使用VBS
谢谢!
您可能需要为您的问题添加更多上下文,但第一个答案是使用ADODB查询数据库,将XML加载到MSXML2中,使用XPath选择要添加结果的节点然后插入字符串作为节点文本。
''#open the data
dim ado: set ado = CreateObject("ADODB.Connection")
ado.ConnectionString = "..."
ado.open
dim rs: set rs = ado.Execute("SELECT TOP 1 your_string FROM your_data_table")
''#open the XML
dim xmldoc: set xmldoc = CreateObject("MSXML2.DomDocument")
xmldoc.async = false
xmldoc.setProperty "SelectionLanguage", "XPath"
''# you might also need setProperty "SelectionNamespaces", "xmlns=..." depending on your XML
xmldoc.load "path\to\your\XML"
''# store the string in the XML and save
xmldoc.selectSingleNode("//xpath/to/your/target/node").text = rs.fields["your_string"].value
xmldoc.save "path\to\your\output\xml"
rs.close
ado.close
如果你在这一点上是已经,让我知道如果您有任何具体问题
感谢您的解决方案,但问题已经解决。 – 2011-03-15 09:28:01
是整个字符串XML? – 2011-03-10 20:37:27
输出必须是xml。输入是来自MSSQL服务器数据库的查询结果 – 2011-03-14 07:34:19