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?


0
beths86 (1)
10/11/2008 9:36:34 AM
dotnet.xml 7266 articles. 0 followers. Follow

2 Replies
670 Views

Similar Articles

[PageSpeed] 44

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/
0
mahotrash (1777)
10/11/2008 11:46:19 AM
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
0
Peter
10/11/2008 1:39:37 PM
Reply:

Similar Artilces:

Intranet hyperlink to specific worksheet in excel file problem
Hello Everyone I have an excel file that is quite large with more than 25 worksheets. I would like to create a hyperlink to each worksheet from ou intranet. I can only create a hyperlink to my excel file that opens at the las point I saved the excel file. I hope that makes sense and anyone who can help me would be muc appreciated Jamie from Australi -- Message posted from http://www.ExcelForum.com Hi Jamie, You can create a link with in Excel to a workbook and specific sheet, http://www.mvps.org/dmcritchie/excel/sheets.htm but I don't think you can create a hyperlink in HTML tha...

Convert multiple XLS files to TXT
I need to convert hundreds of XLS files to TXT. I am aware of File/Save-as and I also tried written a macro. Neither solution is workable even the number of files I have to convert. Does Excel have a mass convert utility? One possibility is to loop through all the files and convert the extension from .xls to .txt. Try: Sub ChangeXLStoTXT() 'Based on some old code from me 'with modifications from Dave Peterson Dim MyFolder As String Dim NewName As String Dim i As Long MyFolder = "C:\Program Files\ztest" '<----Change Application.ScreenUpdating = False With Appli...

XML transformation
There is any way to transforming XML using XSL according with Schema? I need to add arguments to the certain tags according with their datatype. Thanks, Lenny Lenny Woodbridge wrote: > There is any way to transforming XML using XSL according with Schema? I need > to add arguments to the certain tags according with their datatype. XSLT 1.0/XPath 1.0 doesn't have any features to deal with the types defined in XML Schema 1.0. I think XSLT 2/XPath 2 takes some efforts but it is still under development. -- Martin Honnen http://JavaScript.FAQTs.com/ ...

How parse XML values from a string?
I have a string (see below) that I want to parse out the values. As you can see, some are element-based and some are attribute-based. <METADATA version="Format5"><TITLE value="Adrenaline Rush"/><DESCRIPTION>Take a thrilling look at the world of skydiving and base jumping - parachuting from a building, a bridge or a cliff. With breathtaking views of skydiving over the Florida Keys, the Mojave Desert and the magnificent Fjords of Norway, this giant-screen experience explores the psychological and physiological forces behind risk-tasking and the physi...

Outloo 2003 pst file finding?
When I 1st open Outlook 2003 can I press a key to force it to "browse" for a pst file? Huh? Can you rephrase your Question. Are you looking for the pst files or are you looking for a single email as the pst. Very hard to understand what exactly you are looking for and how -- Peter Please Reply to Newsgroup for the benefit of others Requests for assistance by email can not and will not be acknowledged. "JDS" <noway@notnow.net> wrote in message news:%23e1yur1eKHA.4112@TK2MSFTNGP06.phx.gbl... > When I 1st open Outlook 2003 can I press a key t...

XML autoincrement not reflected in DataSet
Hi, When I turn an xml file based on this schema into a dataset using DataSet.ReadXML, Tables[0] ... Column[0] Autoincrement is set to FALSE, and the DataType comes out as System.String. Can anyone explain what I'm doing wrong? I want Column[0] to function as a primary key ie with DataType = integer, Autoincrement=true. TIA, JON <?xml version="1.0" encoding="UTF-8"?> <xs:schema xmlns:xs="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata" elementFormDefault="qualified" attributeFormDe...

Eliminate unused columns
I have a table of columns of data per week, which I convert to a table of columns of data per month. This leaves 3 or 4 blank columns between the months. Is there a simple way to consolidate the month columns into a contiguous region, eliminating the unused columns between the month columns? Or... is there a smarter way to do the conversion than sum across an fill down? One approach is to use a macro: if your empty columns are completely empty you could use this macro. Hit Alt-F11, Click Insert/Module (check the project window to make sure your workbook is the active project before...

working with temporary working files..
I keep getting the message that I cannot save a temp. working file. This work has been save on a cd and transfered back on to my desk top. Help ...

Faster XML Processing...
Need some help on how to make the following faster.... Public XmlDocument ProcessXML( XmlDocument xmlData ) { XmlNode originalXML = xmlData.Clone(); try { // Process XML data here... } catch { // if ANYTHING goes wrong with XML processing // revert back to the original. xmlData.LoadXml(originalXML.OuterXml); return xmlData; } return xmlData; } There it is. Without cloning and reloading in the catch block, if something goes wrong, I get SOME xml processing, which I absolutely cannot have. For example, if some data in ...

Money 2005 "additional progam files are being downloaded"...NOT
I keep getting this message every time I launch money (even after leaving Money up and running overnight on my cable modem). I cannot get into my investment details because Money complains that additional modules are being downloaded. Anybody else seeing this, or have a workaround? suzy What is the patch level on your money 2005? Got to Help About and the last three digits of my version following the download is .825 suzy c wrote: > I keep getting this message every time I launch money (even after > leaving Money up and running overnight on my cable modem). > > I cannot ge...

Problem with file links changing
Good day all. Excel 2007. I have a number of workbooks in memory some having file links referencing a data file also in memory. I have code which firstly saves the current data file (constantly updating) at month end run and then "Saves As" to another directory with a different file name. It then closes the new file and re-opens the original so that processing can continue for the new month. However, my problem is that all files with links to the original data file have now changed to reference the Saved As file!! e.g. VLookup and HLookup. I have tried various avenues ...

Date Elimination
I have a worksheet with mainly dates in column A in the format of '25 Aug 2008'. Is it possible with a macro or similar to delete lines beyond a certain date (2 years hence)? Basically, I'm not interested in data more than 2 years old. This would eliminate a lot of data and make for a more viewable worksheet. try this Sub del_date() ActiveCell.Range("A1").Select Do Until ActiveCell.Value =3D "" dt =3D Date - 730 If ActiveCell.Value <=3D dt Then ActiveCell.ClearContents ActiveCell.Offset(1, 0).Select Else ActiveCell.Offset(1, 0).Select End If Loop End ...

Writing to a text file formatted as XML
Hi! I have a text file that looks like this: <configuration> <appSettings> <add key="db_server" value="someserver" /> <add key="db_database" value="somedatabase" /> </appSettings> </configuration> Now, I want to check if value for db_server is empty and if it is, I want to write the value. I am trying to use XmlTextWriter and XmlTextReader but being new to XML processing I don't know exactly how to do it. Can anyone help please? Regards, Kumar The easiest way would be to load the document in Xml...

How to hide the outlook toolbar when opening an excel file
When I open my excel file the outlook toolbar appears along with all the other toolbars. I do not want to send an email with this file. I just want to open it without the entire outlook tool bar appearing. ...

Encrypt Content In XML
I will have security rights stored in XML data, and I just need the content of elements and/or attributes to be encrypted. When the dotnet application reads in the information, it would run a simple decryption on the data. I have one routine that does this, except is uses hexadecimal characters, so I need it to be valid characters for xml. Any routines out there to do this, encrypt and decrypt data that can be used in XML? Derek ...

eliminating duplicates
I need to elimnate duplicates the following script. I believe what is creating the duplicates is the provcont table, there are different provcont ids for each record. Thanks in advance. SELECT PROVCONT.C_FAX, PROVIDER.NAME, PROVIDER.PROV_PATH, PROVIDER.PROV_ID, PROVSTAT.STATUS, PSTATUS.DESCRIPT, PROVCONT.CONTAC_ID FROM PROVCONT INNER JOIN PROVIDER ON PROVCONT.PROV_ID = PROVIDER.PROV_ID INNER JOIN PROVSTAT ON PROVIDER.PROV_ID = PROVSTAT.PROV_ID INNER JOIN PSTATUS ON PROVSTAT.STATUS = PSTATUS.STATUS WHERE (PROVIDER.PROV_PATH = 2) AND ...

eliminate duplicates
I have a table with 7 different columns of team members on different teams. I need a count of all team members. How do I query seven different columns and eliminate dups? You've discovered yet another problem with denormalized tables. If you have 7 different columns, each containing the same basic information, you have a repeating group. If you can't go back and redesign your tables, the easiest approach would be to create a UNION query that normalizes the data so that it's in only 1 column: SELECT Member1 AS Member FROM MyTable UNION SELECT Member2 AS Member FROM MyTabl...

How to create and use xlw file? Help!
Hi, I had a huge file with numerous links. It can not even auto-calculat the formulas once I made a change. I guess it is just too large. Anyway, I posted a message on another forum and someone suggested t use xlw file so that when I open the xlw file I will open several file linked to xlw file at the same time. And that may do help. I don't have any idea about creating and using xlw file. Anyone know details about it? Pls. help -- Message posted from http://www.ExcelForum.com Start by looking at Save a group of workbooks in a customized workspace in XL Help. In arti...

Copy node values from one xml to the other (tags are removed!)
Hi, I have file1 that looks like this; <A> <user_id><xsl:value-of-select=\"A/user_id\"/></user_id> <context>something</context> </A> Another file with the exist (File2) <A> <user_id>DATAMGR</user_id> <user_name>DATAMGR</user_name> </A> After the transformation, I want File1, to look up value of <user_id/> in File2 so the File1 and ends up with the xml; <A> <user_id>DATAMGR</user_id> <context>something</context> </A> I am not sure how t...

can one convert a .csv file to a .pst file in Outlook 7?
I exported all my old emails in my Personal folders to Office Live Workspace. They savced out in csv form, and show up in Office Live Workspace in a document format. But now when I save them back to the desktop, they save in csv form, and I can's seem to figure out how to get them back in my Outlook 7 in pst file form, so they look like email. I had three years worth of old email that I exported to Office Live Workspace thinking I could just import them back to my Outlook, after having my computer wiped. Now I can't seem to get them back. Did you try using the File, ...

eliminate message from append query to eliminate duplicate record.
Create a new query in design view. Add the two tables for which you wish to compare. When you see the two tables in the design view of the query click on one of your 2 join fields and drag to the corresponding join field in the other table (a line should appear) then double click on fields to add them to the query. For your comparison field Your going to have to explain how you want to compare the two fields. What type of field is in table B, and what kind of comparison do you want to do? You could start with something simple like entering "ComparisonField:Iif(tableA.field1=tableB.field2,...

Excel file does not open
My Excel file with the proper password does not open. If I type password, Excel opens with top bar: Microsoft Excel - [File name] . But it looks like standard Excel without file (blank), most funcutions in the Groups is hidden ( also Show) If the password is type wrong, Excel gives standard information: Password is not correct. (...). Please help. If you first open the Excel application and then from the application try: File > Open... what happens?? -- Gary''s Student - gsnu200747 "Robert" wrote: > My Excel file with the proper password does not open. If I...

vb.net xml namespace xmlns xmldocument
I am using XMLDocument to create my xml. How do I remove the namespace information ? It is being put on all my xml nodes: <MyServ xmlns="http://www....../XInclude> <Timeout xmlns="">100</Timeout <MyServ> I am using CreateElement as such xElem = newXMLConfigDoc.CreateElement("Timeout") xElem.InnerText = "100" rootNode.AppendChild(xElem) What am I doing wrong ?? marfi95 wrote: > I am using XMLDocument to create my xml. How do I remove the > namespace information ? It is being put on all my xml nodes: > &g...

Error 3045 on an MDE file
Hi I hope you can help me with this it is driving me nuts. I've created a database which I needed to give multiple people access to but didn't want them messing so I created an MDE file. I ensured that the MDB file was set to shared, not compacting and set to run users not owners permissions before I converted. However, if one of the users goes into the database, it does not create and LDB file and if anyone else tries to get it, the error message: Could not use <name>; file already in use. (Error 3045) appears. Some of the tables in the MDE files were linking to and MDB fi...

cycle through n files
I've got a series of operations to do on n excel files the directory is the same..the names of the files are 0001..0002...0003...0004..until 0067 How can I do that through a macro?? Hi I have examples here http://www.rondebruin.nl/tips.htm If you need help post back -- Regards Ron de Bruin http://www.rondebruin.nl "Rossella" <rossy77@gmail.com> wrote in message news:1144840532.042950.93010@i39g2000cwa.googlegroups.com... > I've got a series of operations to do on n excel files > the directory is the same..the names of the files are > 0001..0002...0003.....