By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,732 Members | 1,429 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,732 IT Pros & Developers. It's quick & easy.

XML with chinese character problem

P: n/a
In my .net ,i need to generate an xml file , however, user may input a
chinese character, Then , the xml will got something unknow characters. the
following is my code, Does anyone know how to solve it ??

Private Sub Init()
With AMSXML
..Formatting = Formatting.Indented
..Indentation = 4
..IndentChar = " "
..WriteStartDocument()
..WriteDocType("SOGenericInterchange", Nothing, "SOGenericInterchange.dtd",
Nothing)
..WriteStartElement("SOGenericInterchange")
End With

End Sub
Private Sub InterchangeHeaderIdentification()
Try
With AMSXML
..WriteStartElement("InterchangeHeaderIdentificati on")
..WriteElementString("senderID", strSenderid)
..WriteElementString("interchangeControlReference" , strFilename)
..WriteElementString("recipientID", strReceiveId) <--- problem here .
..WriteElementString("payerID", "")
..WriteEndElement()
..............................
Nov 12 '05 #1
Share this Question
Share on Google+
8 Replies


P: n/a
In order to store non-ANSI characters in xml file, you need to define
encoding.
This first line of your xml file should be:
<?xml version="1.0" encoding="utf-8" ?>
or other encoding matches your language.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
In my .net ,i need to generate an xml file , however, user may input a
chinese character, Then , the xml will got something unknow characters.
the
following is my code, Does anyone know how to solve it ??

Private Sub Init()
With AMSXML
.Formatting = Formatting.Indented
.Indentation = 4
.IndentChar = " "
.WriteStartDocument()
.WriteDocType("SOGenericInterchange", Nothing, "SOGenericInterchange.dtd",
Nothing)
.WriteStartElement("SOGenericInterchange")
End With

End Sub
Private Sub InterchangeHeaderIdentification()
Try
With AMSXML
.WriteStartElement("InterchangeHeaderIdentificatio n")
.WriteElementString("senderID", strSenderid)
.WriteElementString("interchangeControlReference", strFilename)
.WriteElementString("recipientID", strReceiveId) <--- problem here .
.WriteElementString("payerID", "")
.WriteEndElement()
.............................

Nov 12 '05 #2

P: n/a
thanks, my XML already got it , but still cannot output chinese character..
"Wencheng Magiya" <go*****************@hotmail.com> 级糶秎ン穝籇:uU**************@TK2MSFTNGP10.phx.g bl...
In order to store non-ANSI characters in xml file, you need to define
encoding.
This first line of your xml file should be:
<?xml version="1.0" encoding="utf-8" ?>
or other encoding matches your language.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
In my .net ,i need to generate an xml file , however, user may input a
chinese character, Then , the xml will got something unknow characters.
the
following is my code, Does anyone know how to solve it ??

Private Sub Init()
With AMSXML
.Formatting = Formatting.Indented
.Indentation = 4
.IndentChar = " "
.WriteStartDocument()
.WriteDocType("SOGenericInterchange", Nothing,
"SOGenericInterchange.dtd",
Nothing)
.WriteStartElement("SOGenericInterchange")
End With

End Sub
Private Sub InterchangeHeaderIdentification()
Try
With AMSXML
.WriteStartElement("InterchangeHeaderIdentificatio n")
.WriteElementString("senderID", strSenderid)
.WriteElementString("interchangeControlReference", strFilename)
.WriteElementString("recipientID", strReceiveId) <--- problem here .
.WriteElementString("payerID", "")
.WriteEndElement()
.............................


Nov 12 '05 #3

P: n/a
Please show how you are constructing the AMSXML writer. It should be
something like this:

new System.Xml.XmlTextWriter(filename, System.Text.Encoding.UTF8)

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
thanks, my XML already got it , but still cannot output chinese
character..
"Wencheng Magiya" <go*****************@hotmail.com>
级糶秎ン穝籇:uU**************@TK2MSFTNGP10.phx.g bl...
In order to store non-ANSI characters in xml file, you need to define
encoding.
This first line of your xml file should be:
<?xml version="1.0" encoding="utf-8" ?>
or other encoding matches your language.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
In my .net ,i need to generate an xml file , however, user may input a
chinese character, Then , the xml will got something unknow characters.
the
following is my code, Does anyone know how to solve it ??

Private Sub Init()
With AMSXML
.Formatting = Formatting.Indented
.Indentation = 4
.IndentChar = " "
.WriteStartDocument()
.WriteDocType("SOGenericInterchange", Nothing,
"SOGenericInterchange.dtd",
Nothing)
.WriteStartElement("SOGenericInterchange")
End With

End Sub
Private Sub InterchangeHeaderIdentification()
Try
With AMSXML
.WriteStartElement("InterchangeHeaderIdentificatio n")
.WriteElementString("senderID", strSenderid)
.WriteElementString("interchangeControlReference", strFilename)
.WriteElementString("recipientID", strReceiveId) <--- problem here .
.WriteElementString("payerID", "")
.WriteEndElement()
.............................



Nov 12 '05 #4

P: n/a
Agnes,

Can you put a breakpoint to see what is in strReceiveId variable?

I made a small application to test, it can write and read Chinese or other
characters OK:
Dim writer As New Xml.XmlTextWriter("test.xml", Encoding.UTF8)

writer.WriteStartDocument()

writer.WriteStartElement("node1")

writer.WriteElementString("English", TextBox1.Text)

writer.WriteElementString("Chinese", TextBox2.Text)

writer.WriteEndElement()

writer.WriteEndDocument()

writer.Flush()

writer.Close()



"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
thanks, my XML already got it , but still cannot output chinese
character..
"Wencheng Magiya" <go*****************@hotmail.com>
glsD:uU**************@TK2MSFTNGP10.phx.gbl...
In order to store non-ANSI characters in xml file, you need to define
encoding.
This first line of your xml file should be:
<?xml version="1.0" encoding="utf-8" ?>
or other encoding matches your language.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
In my .net ,i need to generate an xml file , however, user may input a
chinese character, Then , the xml will got something unknow characters.
the
following is my code, Does anyone know how to solve it ??

Private Sub Init()
With AMSXML
.Formatting = Formatting.Indented
.Indentation = 4
.IndentChar = " "
.WriteStartDocument()
.WriteDocType("SOGenericInterchange", Nothing,
"SOGenericInterchange.dtd",
Nothing)
.WriteStartElement("SOGenericInterchange")
End With

End Sub
Private Sub InterchangeHeaderIdentification()
Try
With AMSXML
.WriteStartElement("InterchangeHeaderIdentificatio n")
.WriteElementString("senderID", strSenderid)
.WriteElementString("interchangeControlReference", strFilename)
.WriteElementString("recipientID", strReceiveId) <--- problem here .
.WriteElementString("payerID", "")
.WriteEndElement()
.............................



Nov 12 '05 #5

P: n/a
Dim writer As New Xml.XmlTextWriter("test.xml", Encoding.UTF8) <-- Already
Exist

IF i set breakpoint, I can see my chinese character in watch window.
However, if i use IE or notepad to read it.
The chinese character still cannot show.
"Wencheng Magiya" <go*****************@hotmail.com> 级糶秎ン穝籇:ui**************@TK2MSFTNGP14.phx.g bl...
Agnes,

Can you put a breakpoint to see what is in strReceiveId variable?

I made a small application to test, it can write and read Chinese or other
characters OK:
Dim writer As New Xml.XmlTextWriter("test.xml", Encoding.UTF8)

writer.WriteStartDocument()

writer.WriteStartElement("node1")

writer.WriteElementString("English", TextBox1.Text)

writer.WriteElementString("Chinese", TextBox2.Text)

writer.WriteEndElement()

writer.WriteEndDocument()

writer.Flush()

writer.Close()



"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
thanks, my XML already got it , but still cannot output chinese
character..
"Wencheng Magiya" <go*****************@hotmail.com>
glsD:uU**************@TK2MSFTNGP10.phx.gbl...
In order to store non-ANSI characters in xml file, you need to define
encoding.
This first line of your xml file should be:
<?xml version="1.0" encoding="utf-8" ?>
or other encoding matches your language.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
In my .net ,i need to generate an xml file , however, user may input a
chinese character, Then , the xml will got something unknow characters.
the
following is my code, Does anyone know how to solve it ??

Private Sub Init()
With AMSXML
.Formatting = Formatting.Indented
.Indentation = 4
.IndentChar = " "
.WriteStartDocument()
.WriteDocType("SOGenericInterchange", Nothing,
"SOGenericInterchange.dtd",
Nothing)
.WriteStartElement("SOGenericInterchange")
End With

End Sub
Private Sub InterchangeHeaderIdentification()
Try
With AMSXML
.WriteStartElement("InterchangeHeaderIdentificatio n")
.WriteElementString("senderID", strSenderid)
.WriteElementString("interchangeControlReference", strFilename)
.WriteElementString("recipientID", strReceiveId) <--- problem here .
.WriteElementString("payerID", "")
.WriteEndElement()
.............................



Nov 12 '05 #6

P: n/a
How big is your xml file? Can you attach it here?

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O5**************@TK2MSFTNGP12.phx.gbl...
Dim writer As New Xml.XmlTextWriter("test.xml", Encoding.UTF8) <-- Already
Exist

IF i set breakpoint, I can see my chinese character in watch window.
However, if i use IE or notepad to read it.
The chinese character still cannot show.
"Wencheng Magiya" <go*****************@hotmail.com> 级糶秎ン穝籇:ui**************@TK2MSFTNGP14.phx.g bl...
Agnes,

Can you put a breakpoint to see what is in strReceiveId variable?

I made a small application to test, it can write and read Chinese or
other characters OK:
Dim writer As New Xml.XmlTextWriter("test.xml", Encoding.UTF8)

writer.WriteStartDocument()

writer.WriteStartElement("node1")

writer.WriteElementString("English", TextBox1.Text)

writer.WriteElementString("Chinese", TextBox2.Text)

writer.WriteEndElement()

writer.WriteEndDocument()

writer.Flush()

writer.Close()



"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
thanks, my XML already got it , but still cannot output chinese
character..
"Wencheng Magiya" <go*****************@hotmail.com>
glsD:uU**************@TK2MSFTNGP10.phx.gbl...
In order to store non-ANSI characters in xml file, you need to define
encoding.
This first line of your xml file should be:
<?xml version="1.0" encoding="utf-8" ?>
or other encoding matches your language.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
> In my .net ,i need to generate an xml file , however, user may input a
> chinese character, Then , the xml will got something unknow
> characters. the
> following is my code, Does anyone know how to solve it ??
>
> Private Sub Init()
> With AMSXML
> .Formatting = Formatting.Indented
> .Indentation = 4
> .IndentChar = " "
> .WriteStartDocument()
> .WriteDocType("SOGenericInterchange", Nothing,
> "SOGenericInterchange.dtd",
> Nothing)
> .WriteStartElement("SOGenericInterchange")
> End With
>
> End Sub
> Private Sub InterchangeHeaderIdentification()
> Try
> With AMSXML
> .WriteStartElement("InterchangeHeaderIdentificatio n")
> .WriteElementString("senderID", strSenderid)
> .WriteElementString("interchangeControlReference", strFilename)
> .WriteElementString("recipientID", strReceiveId) <--- problem here .
> .WriteElementString("payerID", "")
> .WriteEndElement()
> .............................
>
>



Nov 12 '05 #7

P: n/a
Agnes wrote:
Dim writer As New Xml.XmlTextWriter("test.xml", Encoding.UTF8) <--
Already Exist

IF i set breakpoint, I can see my chinese character in watch window.
However, if i use IE or notepad to read it. The chinese character
still cannot show. "Wencheng Magiya"


Try this: Repeat your test using IE and set View->Encoding->Unicode
(UTF-8). Are the characters displayed now?

Cheers,
--
http://www.joergjooss.de
mailto:ne********@joergjooss.de
Nov 12 '05 #8

P: n/a
Then you are doing everything correctly. The strange characters you are
seeing in the file are probably the UTF-8 encoding of those chinese
characters, which is perfectly fine. Whoever is viewing the file must do a
corresponding UTF-8 decode.

See http://msdn.microsoft.com/library/en...lencodings.asp.
"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O5**************@TK2MSFTNGP12.phx.gbl...
Dim writer As New Xml.XmlTextWriter("test.xml", Encoding.UTF8) <-- Already
Exist

IF i set breakpoint, I can see my chinese character in watch window.
However, if i use IE or notepad to read it.
The chinese character still cannot show.
"Wencheng Magiya" <go*****************@hotmail.com>
级糶秎ン穝籇:ui**************@TK2MSFTNGP14.phx.g bl...
Agnes,

Can you put a breakpoint to see what is in strReceiveId variable?

I made a small application to test, it can write and read Chinese or
other characters OK:
Dim writer As New Xml.XmlTextWriter("test.xml", Encoding.UTF8)

writer.WriteStartDocument()

writer.WriteStartElement("node1")

writer.WriteElementString("English", TextBox1.Text)

writer.WriteElementString("Chinese", TextBox2.Text)

writer.WriteEndElement()

writer.WriteEndDocument()

writer.Flush()

writer.Close()



"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O9**************@TK2MSFTNGP10.phx.gbl...
thanks, my XML already got it , but still cannot output chinese
character..
"Wencheng Magiya" <go*****************@hotmail.com>
glsD:uU**************@TK2MSFTNGP10.phx.gbl...
In order to store non-ANSI characters in xml file, you need to define
encoding.
This first line of your xml file should be:
<?xml version="1.0" encoding="utf-8" ?>
or other encoding matches your language.

"Agnes" <ag***@dynamictech.com.hk> wrote in message
news:O1**************@TK2MSFTNGP12.phx.gbl...
> In my .net ,i need to generate an xml file , however, user may input a
> chinese character, Then , the xml will got something unknow
> characters. the
> following is my code, Does anyone know how to solve it ??
>
> Private Sub Init()
> With AMSXML
> .Formatting = Formatting.Indented
> .Indentation = 4
> .IndentChar = " "
> .WriteStartDocument()
> .WriteDocType("SOGenericInterchange", Nothing,
> "SOGenericInterchange.dtd",
> Nothing)
> .WriteStartElement("SOGenericInterchange")
> End With
>
> End Sub
> Private Sub InterchangeHeaderIdentification()
> Try
> With AMSXML
> .WriteStartElement("InterchangeHeaderIdentificatio n")
> .WriteElementString("senderID", strSenderid)
> .WriteElementString("interchangeControlReference", strFilename)
> .WriteElementString("recipientID", strReceiveId) <--- problem here .
> .WriteElementString("payerID", "")
> .WriteEndElement()
> .............................
>
>



Nov 12 '05 #9

This discussion thread is closed

Replies have been disabled for this discussion.