473,385 Members | 1,620 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Problem with ReadXml into DataSet

Hello!

I have created a xml-file by using the writeXml method on a dataset. The
problem arrises when I want to read the xml-file back into a dataset on a
pocket pc application. Some of the fields which are strings have whitespaces
added to end of the values in the dataset but not in the xml-file. How do I
read the xml-file without getting the whitespaces?

This is a part of the xml-file:
- <User>
<Username>hoa</Username>
<Password>hoa</Password>
<Access>1</Access>
</User>
and when it's put into the dataset it's like this:
Username="hoa "

The code I'm using to read the xml-file:

ds = new DataSet();
reader = new XmlTextReader(configs.DataPath);

ds.ReadXml( reader, XmlReadMode.ReadSchema);

Thanks
Linus
Nov 12 '05 #1
1 1747
You can call the string.Trim function before you insert
the data into the dataset. Before assiging the values to
the dataset store them in a temp variable and call the
Trim function. This will delete the whitespaces. Take a
look here: http://msdn.microsoft.com/library/default.asp?
url=/library/en-
us/cpref/html/frlrfsystemstringclasstrimtopic.asp

hth

Sonu
My Blog: http://weblogs.asp.net/sonukapoor/

-----Original Message-----
Hello!

I have created a xml-file by using the writeXml method on a dataset. Theproblem arrises when I want to read the xml-file back into a dataset on apocket pc application. Some of the fields which are strings have whitespacesadded to end of the values in the dataset but not in the xml-file. How do Iread the xml-file without getting the whitespaces?

This is a part of the xml-file:
- <User>
<Username>hoa</Username>
<Password>hoa</Password>
<Access>1</Access>
</User>
and when it's put into the dataset it's like this:
Username="hoa "

The code I'm using to read the xml-file:

ds = new DataSet();
reader = new XmlTextReader(configs.DataPath);

ds.ReadXml( reader, XmlReadMode.ReadSchema);

Thanks
Linus
.

Nov 12 '05 #2

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

Similar topics

11
by: DraguVaso | last post by:
Hi, I should use XML to synchronize the data from different (VB.NET) applications, and I was just wondering which Overloads of these functions ( ReadXmlSchema, ReadXml and WriteXml) goes the...
1
by: Jeffrey A. Voigt | last post by:
I'm having trouble loading some xml data into a dataset via the ReadXML call. I'm loading into the dataset an xml schema prior to the ReadXML call. I see that there IS in fact, 3 records that...
1
by: mr_dom_is | last post by:
Hi I have a little bit of trouble, probably missing the point now sure but: I have a dataset dim ds as new dataset("User") Which is populated with data from a database. When I use
8
by: Nikhilesh Mehendale | last post by:
I have written a web service in C#, .NET 1.1 which reads a XML file into a dataset. This is just a plain XML file. First I use the Dataset.ReadXmlScheme function and pass the XML file to it. Then...
2
by: bfrasca | last post by:
I have a well-formed XML file that I am trying to load into a dataset using the ReadXML method. It keeps telling me that "there are multiple root elements". I can view the data using XML Designer...
2
by: mathieu cupryk | last post by:
I have problems with listboxes in the webform2.cs, the textboxes are working well when I do a click on next. I am missing something. It works with the textboxes. Here is the file: using System;...
1
by: Raymond Du | last post by:
Hi, I am using Dataset's ReadXML method to read an XML file. Here i s my code snippet: Dim dsTemp As New DataSet dsTemp.ReadXml(Server.MapPath("~/data3.xml")) and data3.xml as follow:...
0
by: mr_dom_is | last post by:
Hi I have a little bit of trouble, probably missing the point not sure but: I have a dataset dim ds as new dataset("User") Which is populated with data from a database. When I use
8
by: Thirsty Traveler | last post by:
I have a dataset that is returned from a sql server select that contains metadata and a cached dataset saved in an xml column. I would like to recover the dataset for use in generating a crystal...
1
by: Angel \Java\ Lopez | last post by:
Hi people! I'm running a Visual Studio 2005, Professional, on Windows XP Professional. I've found a little big problem, reading a DataSet. If I try: ds.ReadXml("c:\data.xml") it raises...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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...

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.