Click here to Skip to main content
15,883,705 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
hi all,

I am working on xml with windows.
successfully complete my test applicatio and created the setup with xml(static) file.

finally installed my system.

when I run the setup error is came.

Error:Data at the root level is invalid. Line 1, position 1.
//when I run the local is working fine but in setup error is came

my xml file is

<?xml version="1.0" encoding="utf-8"?>
<Users>
  <User>
    <UserName>admin</UserName>
    <Password>admin</Password>
    <Role>Admin</Role>
  </User>
</Users>


how to read the xml(it is located on .exe path) file?
Posted
Updated 4-Apr-13 21:20pm
v2
Comments
Zoltán Zörgő 5-Apr-13 3:01am    
What about posting relevant part of the xml here?
U@007 5-Apr-13 3:03am    
like xml(database).it is testing.
Zoltán Zörgő 5-Apr-13 3:05am    
????
U@007 5-Apr-13 3:09am    
I am storing users details in xml file so when login I just validate from xml.
Zoltán Zörgő 5-Apr-13 3:11am    
I have encountered such error when my xml was not encoded as UTF-8 without BOM. Please check this.

1 solution

First off, look at the XML file itself - make sure it exists, and then look at the content. The error message is very specific - it says that the first character in the file if wrong, so at a guess, it isn't a '<' character - it's probably the wrong file. The other possibility is that it's in the wrong place: this could be a permissions issue. It is a poor idea to store any data files in the exe folder unless they are always going to be opened in read only mode - very often, any write access opening will fail security policies in relesae versions, and you will get an error - so it could be how you are opening the file. If you need it to a be read-write file, then move it to a more useful place: Where should I store my data?[^] should help
 
Share this answer
 
Comments
Orcun Iyigun 5-Apr-13 3:12am    
Good answer. 5'ed.
U@007 5-Apr-13 3:16am    
locally it's working fine. in setup not working.my file is see above my question is updated.
OriginalGriff 5-Apr-13 3:41am    
Locally is different - the app isn't in the "Program Files" folder tree which is a lot more restrictive about what you can do with it without admin permissions. "Modern" OS's don't like any write access to such files since it *could* be virus activity. Try an experiment - move the file to "my documents" and see if it works there.

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



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