473,473 Members | 2,145 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

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?
Oct 11 '08 #1
2 7607
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/
Oct 11 '08 #2
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
Oct 11 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Prawdziwa Blondynka | last post by:
Hi, I would like to do the following with C++ and Xerces: set the schema path in an XML file to parse in this way: XMLCh* schemaLocation = XMLString::transcode(namespaceAndPath);...
0
by: hy | last post by:
Hi all, I got a problem to restore back the selected upload file after i fired a radio button that will call the server script to do the process. In my aspx page, i have an upload textbox to...
6
by: mardif | last post by:
Hi guys. I've a very big big big problem: I've in my windows computer a file named cicciobello.html, located in c:\documents and settings\username\desktop\cicciobello.html. Now, I MUST open...
6
by: mathieu.malaterre | last post by:
Hello, I cannot figure out a way to find a regular expression that would match one and only one of these two strings: s1 = ' how are you' s2 = ' hello world ...
2
by: rn5a | last post by:
When a Button is clicked in a Form, the JavaScript 'prompt' dialog pops-up for users to enter any text. When the user clicks OK in the prompt dialog, the text is populated in a TextBox & the Form...
1
AdrianH
by: AdrianH | last post by:
Assumptions I am assuming that you know or are capable of looking up the functions I am to describe here and have some remedial understanding of C programming. FYI Although I have called this...
6
by: Frankie | last post by:
What would it take to send a page to a browser - and the HTML that comprises that "page" is 100% generated dynamically? Specifically, say I have all of the requisite HTML in a string variable....
9
by: Saravanan Krishnan | last post by:
Hi, i'm writting a windows application in C# the functionality that i'm trying is to implement is to add items to a combo box at run time & when i select one item, my app should filter the list...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.