Whitespace is not allowed at this location

Posted by in Error and Solution category on for Beginner level | Views : 21166 red flag
Rating: 5 out of 5  
 1 vote(s)

Errors And Resolution encountered by Programmers in their daily life
Am not a fan of Ado.net in xmland that is because its sometimes so consfusing and time consuming if you have get a work around for a problem of mulformed tags in the xml, well i might not be a fan but the previous programmer whom i inherited the project from was a fan of XML. well in a web application everything is xml based, database manupilation is done in xml, a lot of serialization and desirialization. it will take you more that ten lines of code , doing the looping to save data to SQL through a large dataset , but if you use straight ado.net object it will take you 5 or less lines and it depends on the parameters. now lets get to the point of this Blog.
xml that reads

XML comment contains invalid XML: Whitespace is not allowed at this location".

This is because in your Column fields that you pass to the Xml there is ampresant and in XML its a special character, now you need to turn it off. well in my case and your case its simple , you need to leave your code the way it and in your code where you pass the xml string, you must use the replace function in C# or Vb.net like this


Xml.Replace("&", "& amp;");

the "&" will turn it off and everything will be good again.

Thank you for Visiting Dotnetfunda

Vuyiswa Maseko

Page copy protected against web site content infringement by Copyscape

About the Author

Full Name: Vuyiswa Maseko
Member Level: NotApplicable
Member Status: Member,MVP,Administrator
Member Since: 7/6/2008 11:50:44 PM
Country: South Africa
Thank you for posting at Dotnetfunda [Administrator]
Vuyiswa Junius Maseko is a Founder of Vimalsoft (Pty) Ltd (http://www.vimalsoft.com/) and a forum moderator at www.DotnetFunda. Vuyiswa has been developing for 16 years now. his major strength are C# 1.1,2.0,3.0,3.5,4.0,4.5 and vb.net and sql and his interest were in asp.net, c#, Silverlight,wpf,wcf, wwf and now his interests are in Kinect for Windows,Unity 3D. He has been using .net since the beta version of it. Vuyiswa believes that Kinect and Hololen is the next generation of computing.Thanks to people like Chris Maunder (codeproject), Colin Angus Mackay (codeproject), Dave Kreskowiak (Codeproject), Sheo Narayan (.Netfunda),Rajesh Kumar(Microsoft) They have made vuyiswa what he is today.

Login to vote for this post.

Comments or Responses

Login to post response

Comment using Facebook(Author doesn't get notification)