Problem with readXml into DataSet

  • Thread starter Thread starter Linus Rörstad
  • Start date Start date
L

Linus Rörstad

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
 
Linus

I noticed there is only a portion of the XML file. If your XML file contains schema information regarding field lengths, and there Username is a fixed length string field that could be responsible for padding out the value with spaces when it is read into the DataSet

Regard

Liam Westley
 
DataSet.ReadXml() will not add nor remove spaces to/from data in the XML
file.

IE, on the other hand, will hide spaces. For example, this one <foo> Hello
</foo> looks like this in IE: <foo>Hello</foo>

These spaces are in your XML. You should remove spaces from the XML file
you're loading if you don't need them.

Best regards,

Ilya

This posting is provided "AS IS" with no warranties, and confers no rights.

--------------------
 
Back
Top