存储到sql 2005数据库时的XML编码问题。 [英] XML encoding problems when storing to sql 2005 database.

查看:68
本文介绍了存储到sql 2005数据库时的XML编码问题。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你好


我搜索了这个论坛,似乎有些人对我有类似的问题,但没有一个修复正在修复我的...! :(


我的数据库中有一个表有两个xml字段。


我有两位生成的XML我要存储..第一个具有

"<?xml version =" 1.0" encoding =" utf-8"?>"作为其声明,第二个具有<< ;?xml version =" 1.0" encoding =" utf-16"?>"


第一次将这两者都添加到数据库中,没有错误如果我回去尝试编辑,那么就会出现问题!


xml再次生成与第一次添加到数据库时生成的函数相同,但这次第一次更新没有错误,但第二次给出错误XML解析:第1行,第38行,无法切换编码。


从我的内容看来SQL Server似乎必须将xml编码为UTF-16。如果是这样的话,我不明白为什么我的UTF-8 xml没问题,但是使用我的UTF-16!


我试图在调试模式下更改文件的UTF设置,如果我将编码更改为UTF,则会插入第二个设置8当我进行更新时,如果我把它留下,当我第一次尝试插入时会出现同样的错误



无论如何看到的是什么编码真的在我的xml上,看它是否与声明中的内容不同?然后将其转换为UTF-16应该是什么?


非常感谢提前


Bex

Hello

I have searched through this forum and it seems some people are having similar problems to me but none of the fixes are fixing mine..! :(

I have a table in my database that has two xml fields.

I have two bits of generated XML I want to store.. the first one has
"<?xml version="1.0" encoding="utf-8" ?>" as its declaration and the second has "<?xml version="1.0" encoding="utf-16" ?>"

First time round these both get added to the database fine, with no errors. If I go back and try and edit I then get problems!

The xml gets generated again in the same function as it is generated the first time when it is added to the database, but this time the first one updates with no errors, but the second gives the error "XML parsing: line 1, character 38, unable to switch the encoding".

From what I have read it seems that SQL Server must have the xml encoded as UTF-16. If this is the case, I don''t understand why I have no problems with my UTF-8 xml, but do with my UTF-16!

I have tried changing the UTF setting on the file in debug mode and the second one will insert if I change the encoding to UTF-8 when I do the update, but it gives the same error if I leave it as that when I try and insert the first time


Is there anyway of seeing what the encoding really is on my xml, to see if it is different to what it says in the declaration? And then to convert it to UTF-16 as it should be?

Thanks so much in advance

Bex

推荐答案


你好


我搜索了这个论坛,似乎有些人有类似的我遇到的问题,但没有一个修复正在修复我的..! :(


我的数据库中有一个表有两个xml字段。


我有两位生成的XML我要存储..第一个具有

"<?xml version =" 1.0" encoding =" utf-8"?>"作为其声明,第二个具有<< ;?xml version =" 1.0" encoding =" utf-16"?>"


第一次将这两者都添加到数据库中,没有错误如果我回去尝试编辑,那么就会出现问题!


xml再次生成与第一次添加到数据库时生成的函数相同,但这次第一次更新没有错误,但第二次给出错误XML解析:第1行,第38行,无法切换编码。


从我的内容看来SQL Server似乎必须将xml编码为UTF-16。如果是这样的话,我不明白为什么我的UTF-8 xml没问题,但是使用我的UTF-16!


我试图在调试模式下更改文件的UTF设置,如果我将编码更改为UTF,则会插入第二个设置8当我进行更新时,如果我把它留下,当我第一次尝试插入时会出现同样的错误



无论如何看到的是什么编码真的在我的xml上,看它是否与声明中的内容不同?然后把它转换成UTF-16应该是吗?


非常感谢提前


Bex
Hello

I have searched through this forum and it seems some people are having similar problems to me but none of the fixes are fixing mine..! :(

I have a table in my database that has two xml fields.

I have two bits of generated XML I want to store.. the first one has
"<?xml version="1.0" encoding="utf-8" ?>" as its declaration and the second has "<?xml version="1.0" encoding="utf-16" ?>"

First time round these both get added to the database fine, with no errors. If I go back and try and edit I then get problems!

The xml gets generated again in the same function as it is generated the first time when it is added to the database, but this time the first one updates with no errors, but the second gives the error "XML parsing: line 1, character 38, unable to switch the encoding".

From what I have read it seems that SQL Server must have the xml encoded as UTF-16. If this is the case, I don''t understand why I have no problems with my UTF-8 xml, but do with my UTF-16!

I have tried changing the UTF setting on the file in debug mode and the second one will insert if I change the encoding to UTF-8 when I do the update, but it gives the same error if I leave it as that when I try and insert the first time


Is there anyway of seeing what the encoding really is on my xml, to see if it is different to what it says in the declaration? And then to convert it to UTF-16 as it should be?

Thanks so much in advance

Bex



如何从数据库中读取XML以进行编辑?代码,请。

How do you read the XML back from the database for edit? Code, please.


您好


我从数据库中获取它作为字符串然后去

Hi

I get it from the database as a string and then go

展开 | 选择 | Wrap | 行号






我从中得到它将数据库作为字符串然后去

Hi

I get it from the database as a string and then go

展开 | 选择 | Wrap | 行号


这篇关于存储到sql 2005数据库时的XML编码问题。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆