Reputation: 2387
I am working in C#.Net. I am generating a XML and Binding it to a treeview. Here is my code part..
sb.Append("<?xml version='1.0' encoding='utf-8'?>");
sb.Append("<astreeview xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance'>");
sb.Append("<astreeview-nodes>");
...........................
In my local machine its working fine and also i had deployed in 2 different servers. In one server, i am getting the treeview correctly. But in another server, i am getting the error like..
Unexpected XML declaration. The XML declaration must be the first node in the document, and no white space characters are allowed to appear before it. Line 1, position 12285.
Same code is used in both the servers. What might be the issue here...
Upvotes: 0
Views: 11307
Reputation: 32787
It appears that you have some white space or other characters in that string
Remove it..
Clear the string builder and then appendLine it
sb.Clear();
sb.AppendLine("<?xml version='1.0' encoding='utf-8'?>");
Upvotes: 2