Eliza wrote:
we have written a C# program which generates an XML file from a
Client computer and this file is being transfered to the Server
side(using Socket programming). at the Server side we are first
extracting the data from the XML file into a Dataset and using the
method Dataset.ReadXml() we are trying to parse the nodes in the file.
But on debugging the following exception arises---
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 59, position 16.
According to us, the problem occurs when the file is being transfered
from the client to the server, some extra bytes are also transfered.
Is there any solution to the problem?
Use software that does not add extra bytes :-)
But what is interesting is that the error is reported at line 59:16.
This implies that there are 58 blank lines being inserted before the XML
Declaration, which doesn't sound very likely. Character position 16 in
the default XML Declaration is...
<?xml version="1.0"?>
1234567890123456
....the first character of the version number, which is also an odd place
to report an error. I would have expected position 6, the point at which
it becomes clear to the parser that the XML Declaration PI name is 'xml'.
Are there really 58 blank lines at the start of the file? Or is the file
perhaps 59 lines long, ending with an end-tag for the root element type
which happens to be 15 characters long?
As Martin said, unless you can give us more information, it's not
possible to give a useful answer.
///Peter