473,320 Members | 2,164 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,320 software developers and data experts.

XML Characters not moved correctly to Data Set

I have a problem where the French translation for "side" gets converted
incorrectly into a datatable from XML.

Note:
The total XML is at the bottom of the message to keep from distracting from
the observation.

Note: The characters used in this example are <Text>Côtés</Text>

When I put the XML into a datatable doing either of the following it gets
converted to "C?t?s"

Method 1: "US-ASCII"
ASCIIEncoding en = new ASCIIEncoding();
byte[] XML = en.GetBytes(sWork);
MemoryStream memory_streamXLM = new
MemoryStream(XML,0,XML.Length,true,true);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMod e.ReadSchema);

Method 2: "Unicode (UTF-8)"
UTF8Encoding utf8 = new UTF8Encoding();
Byte[] XML = utf8.GetBytes(sWork);
MemoryStream memory_streamXLM = new MemoryStream(XML);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMod e.ReadSchema);
?ds.Tables[0].Rows[6][6]
"C?t?s"

What do I need to do?
--
Eagle Eye

Total XLM for LanguageItems

"<TableInfo>\n <xs:schema id=\"TableInfo\" xmlns=\"\"
xmlns:xs=\"http://www.w3.org/2001/XMLSchema\"
xmlns:msdata=\"urn:schemas-microsoft-com:xml-msdata\">\n <xs:element
name=\"TableInfo\" msdata:IsDataSet=\"true\">\n <xs:complexType>\n
<xs:choice maxOccurs=\"unbounded\">\n <xs:element
name=\"Table1\">\n <xs:complexType>\n <xs:sequence>\n
<xs:element name=\"LanguageItemID\"
msdata:DataType=\"System.Guid, mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089\" type=\"xs:string\" minOccurs=\"0\" />\n
<xs:element name=\"LanguageID\" msdata:DataType=\"System.Guid,
mscorlib, Version=1.0.5000.0, Culture=neutral,
PublicKeyToken=b77a5c561934e089\" type=\"xs:string\" minOccurs=\"0\" />\n
<xs:element name=\"StoreTable\" type=\"xs:string\" minOccurs=\"0\"
/>\n <xs:element name=\"RowVariable\" type=\"xs:string\"
minOccurs=\"0\" />\n <xs:element name=\"RowValue\"
type=\"xs:stri
ng\" minOccurs=\"0\" />\n <xs:element name=\"ColumnName\"
type=\"xs:string\" minOccurs=\"0\" />\n <xs:element
name=\"Text\" type=\"xs:string\" minOccurs=\"0\" />\n
<xs:element name=\"Active\" type=\"xs:boolean\" minOccurs=\"0\" />\n
<xs:element name=\"BusID\" msdata:DataType=\"System.Guid, mscorlib,
Version=1.0.5000.0, Culture=neutral, PublicKeyToken=b77a5c561934e089\"
type=\"xs:string\" minOccurs=\"0\" />\n <xs:element
name=\"LastUpdated\" type=\"xs:dateTime\" minOccurs=\"0\" />\n
<xs:element name=\"WebReportsTransmitted\" type=\"xs:boolean\"
minOccurs=\"0\" />\n <xs:element
name=\"WebReportsTransmitSuccessfull\" type=\"xs:boolean\" minOccurs=\"0\"
/>\n </xs:sequence>\n </xs:complexType>\n
</xs:element>\n </xs:choice>\n </xs:complexType>\n
</xs:element>\n </xs:schema>\n <Table1>\n
<LanguageItemID>030fa9ce-d6e5-4c0f-8470-0697844a7932</LanguageItemID>\n
<LanguageID>e32f05bf-466a-4b2d-821d-fef92549ae60</LanguageID>\n
<StoreTable>tblOrderType</StoreTable>\n
<RowVariable>OrderTypeID</RowVariable>\n
<RowValue>a0f5402c-77e9-45df-a586-afa111616432</RowValue>\n
<ColumnName>Ordtype_Dsc</ColumnName>\n <Text>Pickup Orders</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-21T09:36:08.4200000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>12901025-05a9-475c-bb30-1e01fb2615a8</LanguageItemID>\n
<LanguageID>e32f05bf-466a-4b2d-821d-fef92549ae60</LanguageID>\n
<StoreTable>tblMenuPadGroup</StoreTable>\n
<RowVariable>MenuPadGroupID</RowVariable>\n
<RowValue>78441e60-80bf-40ac-889d-d4eb5f241729</RowValue>\n
<ColumnName>Menu_Pad_Grp_Label</ColumnName>\n <Text>Sides</Text>\n
<Active>true</Active>\n <BusID>e1b68da2-4796-4240-88
81-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-24T21:38:29.7630000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>713c969b-f50f-4162-af14-292ab5b587ca</LanguageItemID>\n
<LanguageID>34dc0255-a27e-44d2-86bb-c3591d7e41d2</LanguageID>\n
<StoreTable>tblOrderType</StoreTable>\n
<RowVariable>OrderTypeID</RowVariable>\n
<RowValue>22f35979-a34a-4d69-8911-83ff6878e63d</RowValue>\n
<ColumnName>Ordtype_Dsc</ColumnName>\n <Text>Dinez Dedans</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-21T09:36:08.4370000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>d95fe9a1-7ea7-41b8-a1f0-6d5241478b48</LanguageItemID>\n
<LanguageID>e32f05bf-466a-
4b2d-821d-fef92549ae60</LanguageID>\n
<StoreTable>tblOrderType</StoreTable>\n
<RowVariable>OrderTypeID</RowVariable>\n
<RowValue>22f35979-a34a-4d69-8911-83ff6878e63d</RowValue>\n
<ColumnName>Ordtype_Dsc</ColumnName>\n <Text>Dine In</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-21T09:36:08.4370000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>aa016800-62cb-4486-a533-7ef80f2fa141</LanguageItemID>\n
<LanguageID>e32f05bf-466a-4b2d-821d-fef92549ae60</LanguageID>\n
<StoreTable>tblOrderType</StoreTable>\n
<RowVariable>OrderTypeID</RowVariable>\n
<RowValue>ea167a07-d003-43b0-8e13-804cd73c2670</RowValue>\n
<ColumnName>Ordtype_Dsc</ColumnName>\n <Text>Take Out Orders</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n <LastUp
dated>2005-10-21T09:36:08.4370000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>3de73137-4f45-491f-bd82-a27ec1077910</LanguageItemID>\n
<LanguageID>fb590c3c-e772-4109-8d5f-3c9d75261002</LanguageID>\n
<StoreTable>tblMenuPadGroup</StoreTable>\n
<RowVariable>MenuPadGroupID</RowVariable>\n
<RowValue>78441e60-80bf-40ac-889d-d4eb5f241729</RowValue>\n
<ColumnName>Menu_Pad_Grp_Label</ColumnName>\n <Text>Lados</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-24T21:38:29.9670000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>02f65777-f4af-4c15-83f5-c0a395a1c4e1</LanguageItemID>\n
<LanguageID>34dc0255-a27e-44d2-86bb-c3591d7e41d2</Langua
geID>\n <StoreTable>tblMenuPadGroup</StoreTable>\n
<RowVariable>MenuPadGroupID</RowVariable>\n
<RowValue>78441e60-80bf-40ac-889d-d4eb5f241729</RowValue>\n
<ColumnName>Menu_Pad_Grp_Label</ColumnName>\n <Text>Côtés</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-24T23:51:17.9030000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n <Table1>\n
<LanguageItemID>a5534d53-8a8b-490e-9285-f69a323aa13d</LanguageItemID>\n
<LanguageID>fb590c3c-e772-4109-8d5f-3c9d75261002</LanguageID>\n
<StoreTable>tblOrderType</StoreTable>\n
<RowVariable>OrderTypeID</RowVariable>\n
<RowValue>22f35979-a34a-4d69-8911-83ff6878e63d</RowValue>\n
<ColumnName>Ordtype_Dsc</ColumnName>\n <Text>Cene Adentro</Text>\n
<Active>true</Active>\n
<BusID>e1b68da2-4796-4240-8881-63770b19a2fc</BusID>\n
<LastUpdated>2005-10-21T09:36
:08.4370000-07:00</LastUpdated>\n
<WebReportsTransmitted>false</WebReportsTransmitted>\n
<WebReportsTransmitSuccessfull>false</WebReportsTransmitSuccessfull>\n
</Table1>\n</TableInfo>"

Oct 26 '05 #1
7 1650
Hi,

Since you are using some French characters, you cannot use the ASCII
encoding to encode the xml file. However, the UTF-8 encoding has to work.
Have you tried with Unicode (UTF-16) encoding instead?

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

Oct 26 '05 #2
Hi,

Did you just try

ds.readxml(thepath)

France is using code table 1252 as most western Europe countries or
countries which uses languages original from that use.

I hope this helps,

Cor
Oct 26 '05 #3
u260044 <u2*****@nospam.nospam> wrote:
I have a problem where the French translation for "side" gets converted
incorrectly into a datatable from XML.

Note:
The total XML is at the bottom of the message to keep from distracting from
the observation.

Note: The characters used in this example are <Text>C?t?s</Text>

When I put the XML into a datatable doing either of the following it gets
converted to "C?t?s"

Method 1: "US-ASCII"
ASCIIEncoding en = new ASCIIEncoding();
byte[] XML = en.GetBytes(sWork);
MemoryStream memory_streamXLM = new
MemoryStream(XML,0,XML.Length,true,true);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMod e.ReadSchema);
Well that certainly won't work, as accented characters aren't part of
ASCII.
Method 2: "Unicode (UTF-8)"
UTF8Encoding utf8 = new UTF8Encoding();
Byte[] XML = utf8.GetBytes(sWork);
MemoryStream memory_streamXLM = new MemoryStream(XML);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMod e.ReadSchema);

?ds.Tables[0].Rows[6][6]
"C?t?s"


Does your XML include a full XML declaration, preferrably including the
encoding (not strictly necessary for UTF-8, but advisable)? If so, I'd
expect the latter to work.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 26 '05 #4
Kevin,

I tried the UTF-8 again and it worked. Thanks! I tried to find something on
UTF-16 and found Unicode so tried that. It did not work when it tried to
create the dataset.

Here is the code I tried. Where did I go wrong? Recall, sWork is a fully
qualified XML statement including a full table schema.

UnicodeEncoding unicode = new UnicodeEncoding();
XML = unicode.GetBytes(sWork);
memory_streamXLM = new MemoryStream(XML,0,XML.Length,true,true);
ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMod e.ReadSchema);

--
Eagle Eye
"Kevin Yu [MSFT]" wrote:
Hi,

Since you are using some French characters, you cannot use the ASCII
encoding to encode the xml file. However, the UTF-8 encoding has to work.
Have you tried with Unicode (UTF-16) encoding instead?

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

Oct 26 '05 #5
Creating the Small Complete Solution to demonstrate proved you were correct.
If you still want it I can provide the small solution that demonstrates the
problem and the solution.

Thanks again.
--
Eagle Eye
"Jon Skeet [C# MVP]" wrote:
u260044 <u2*****@nospam.nospam> wrote:
I have a problem where the French translation for "side" gets converted
incorrectly into a datatable from XML.

Note:
The total XML is at the bottom of the message to keep from distracting from
the observation.

Note: The characters used in this example are <Text>C?t?s</Text>

When I put the XML into a datatable doing either of the following it gets
converted to "C?t?s"

Method 1: "US-ASCII"
ASCIIEncoding en = new ASCIIEncoding();
byte[] XML = en.GetBytes(sWork);
MemoryStream memory_streamXLM = new
MemoryStream(XML,0,XML.Length,true,true);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMod e.ReadSchema);


Well that certainly won't work, as accented characters aren't part of
ASCII.
Method 2: "Unicode (UTF-8)"
UTF8Encoding utf8 = new UTF8Encoding();
Byte[] XML = utf8.GetBytes(sWork);
MemoryStream memory_streamXLM = new MemoryStream(XML);
DataSet ds = new DataSet();
ds.ReadXml(memory_streamXLM,System.Data.XmlReadMod e.ReadSchema);

?ds.Tables[0].Rows[6][6]
"C?t?s"


Does your XML include a full XML declaration, preferrably including the
encoding (not strictly necessary for UTF-8, but advisable)? If so, I'd
expect the latter to work.

Could you post a short but complete program which demonstrates the
problem?

See http://www.pobox.com/~skeet/csharp/complete.html for details of
what I mean by that.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too

Oct 26 '05 #6
u260044 <u2*****@nospam.nospam> wrote:
Creating the Small Complete Solution to demonstrate proved you were correct.
If you still want it I can provide the small solution that demonstrates the
problem and the solution.


No, that's okay, but thanks for the offer.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Oct 27 '05 #7
Hi,

Did the Unicode case throw any exceptions with any error message?

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

Oct 27 '05 #8

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

Similar topics

2
by: JT | last post by:
i don't know why i can't find this anywhere but - what is the maximum number of characters that a string variable can hold - i initially thought it was 256, but after some testing it seems that...
3
by: Andy B | last post by:
I've tried using Trim or RTrim to strip trailing space characters from my data. When I check on the transformed data space characters are still there. We have an address table containing two...
2
by: Renuka | last post by:
Hello, I have to retrive 2 columns from the database which have HTML characters like &lt; &gt; (the less than"<" and greater than sign ">")in their data. Is there any function in C# which can do...
7
by: u260044 | last post by:
I have a problem where the French translation for "side" gets converted incorrectly into a datatable from XML. Note: The total XML is at the bottom of the message to keep from distracting from...
1
by: romiko2000 | last post by:
Hi Folks, I got a weird problem, I create an XMLWriter to post a document via the webrequest stream and after running a network trace, I notice the data is prefixed with 3 invalid characters! ...
1
by: seeCoolGuy | last post by:
I've been using Access to import some data straight into a sql server database by simply importing the xml file. However lately some of the newer xml files will contain vaild data such as ...
0
by: ChrisN | last post by:
My app displays a dataset in a GridView and also exports it to Excel. Characters with diacritical marks (eg umlaut) show up just fine in the GridView but are mangled when exported to Excel. Eg ...
5
by: goldenbear | last post by:
Has anyone experienced where only one person using a shared Access 2003 db in a muti-user environment displays unreadable characters in the header and field of a datasheet subform?
2
by: maheswaran | last post by:
Hi, I have these values in my table empl id desc 1 sample 2 sample1:
0
by: DolphinDB | last post by:
The formulas of 101 quantitative trading alphas used by WorldQuant were presented in the paper 101 Formulaic Alphas. However, some formulas are complex, leading to challenges in calculation. Take...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
0
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.