I am trying to do a xml upload and i get the The file could not be uploaded. The following error occured: Data at the root level is invalid. Line 1, position 1. error below is my code,
During the doc1.LoadXml(xml) ,the exceptino is thrown. What is the way for me to prevent this and interestingly i gett the string as identical as the original files content and the original file i checked if it is proper xml in a external site and it is a valid xml document, so what am i doing wrong here?
string filename = Path.GetFileName(FileUpload1.FileName);
Stream str = FileUpload1.FileContent;
Byte pricingdata = new Byte[FileUpload1.FileContent.Length];
str.Read(pricingdata, 0, FileUpload1.PostedFile.ContentLength);
string xml = Encoding.UTF8.GetString(pricingdata);