Click here to Skip to main content
15,920,663 members
Please Sign up or sign in to vote.
3.00/5 (1 vote)
See more:
Getting
C#
Data at the root level is invalid. Line 1, position 1
while insertion result in database by passing xml as input to stored procedure.

It happens iff xml data contains '&' character in it.

Please reply..??
Posted
Comments
George Jonsson 29-Oct-15 18:40pm    
Show the XML data you are sending. Without that it is impossible to give better help than Solution 1 already does.

1 solution

Refer - XML Specification[^]
Quote:
The ampersand character (&) and the left angle bracket (<) may appear in their literal form only when used as markup delimiters, or within a comment, a processing instruction, or a CDATA section. If they are needed elsewhere, they must be escaped using either numeric character references or the strings "&amp;" and "&lt;" respectively.
 
Share this answer
 
v2
Comments
Member 11774876 29-Oct-15 9:37am    
I have used " Server.HtmlEncode()" for encoding it replace '&' whith & but still not solved error..! :-(
It should work. I think you have other issue then. Try to find out.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS


CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900