1

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?

3
  • I think your sample code got lost, please edit question so we can help you. Commented Nov 16, 2011 at 6:40
  • Mayur put some code. It help peers to understand problem better Commented Nov 16, 2011 at 6:40
  • He's losing a space ' ' character in the <content> element Commented Nov 16, 2011 at 6:40

3 Answers 3

2

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>
Sign up to request clarification or add additional context in comments.

Comments

1

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.

Comments

0

have you tried to use <!CDATA[ ]>?

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.