Register FAQ Members List Calendar Search Today's Posts Mark Forums Read
 

Go Back   XSL - XML - RSS Forums > XML General > .NET and XML

Tags:



Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 10-11-2008, 11:04 AM
Eliza
 
Posts: n/a

Default how to eliminate whitespaces from an XML file



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?


Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 10-11-2008, 01:57 PM
Martin Honnen
 
Posts: n/a

Default Re: how to eliminate whitespaces from an XML file

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?


How do you create the XML exactly and how do you transfer it to the
server exactly? How do you receive the XML on the server? Somewhere you
seem to insert white space but we can't tell unless you share the code
you use.
--

Martin Honnen --- MVP XML
http://JavaScript.FAQTs.com/
Reply With Quote
  #3 (permalink)  
Old 10-11-2008, 06:17 PM
Peter Flynn
 
Posts: n/a

Default Re: how to eliminate whitespaces from an XML file

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
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



Contact Us -|- XSL - XML - RSS Forums -|- Archive -|- Top -|-Rules/Disclaimer-|-Help/Support -|-Advertise
© Camley Interactive (camley.info) 2008 - all logos and images are copywrite their respective owners.
Proud member of the Camley Interactive Network
Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0 ©2007, Crawlability, Inc.
All times are GMT. The time now is 10:03 PM.
Style Developed by Epic Designz