Reputation: 35
I'm trying to send XML in following format from C# (DataType string) to SQL Server stored proc:
<Content> </Content>
There is a space which should get stored as it is in SQL Server column. But it gets stored like <Content/>
. So in nutshell there is loss of space from c# to SQL Server.
Is there anyway I can avoid this?
Upvotes: 1
Views: 380
Reputation: 12468
You can add an attribute xml:space="preserve"
. That helps in "normal" serialization context, I don't know if it will help you in your special context.
Upvotes: 1
Reputation: 56419
The two fragments are equivalent; SQL server is just optimizing the XML.
Is there a particular reason you need the space in there? If so, you might try xml:space="preserve"
, like so:
<Content xml:space="preserve"> </Content>
Upvotes: 2