trouble with rexml

H

hongseok.yoon

I read XML file using REXML.
The XML file contains Korean charactors.

If I print the file using REXML::Document.write $stdout, everything is
okay.( means Korean is printed out narmaly )
But, if I try again using REXML::Element.text, Korean charactors are
broken.( some strange charactors )

ARe there any solution for this?
 
G

Gyoung-Yoon Noh

T24gMi8yMi8wNiwgaG9uZ3Nlb2sueW9vbkBnbWFpbC5jb20gPGhvbmdzZW9rLnlvb25AZ21haWwu
Y29tPiB3cm90ZToKPiBJIHJlYWQgWE1MIGZpbGUgdXNpbmcgUkVYTUwuCj4gVGhlIFhNTCBmaWxl
IGNvbnRhaW5zIEtvcmVhbiBjaGFyYWN0b3JzLgo+Cj4gSWYgSSBwcmludCB0aGUgZmlsZSB1c2lu
ZyBSRVhNTDo6RG9jdW1lbnQud3JpdGUgJHN0ZG91dCwgZXZlcnl0aGluZyBpcwo+IG9rYXkuKCBt
ZWFucyBLb3JlYW4gaXMgcHJpbnRlZCBvdXQgbmFybWFseSApCj4gQnV0LCBpZiBJIHRyeSBhZ2Fp
biB1c2luZyBSRVhNTDo6RWxlbWVudC50ZXh0LCBLb3JlYW4gY2hhcmFjdG9ycyBhcmUKPiBicm9r
ZW4uKCBzb21lIHN0cmFuZ2UgY2hhcmFjdG9ycyApCj4KPiBBUmUgdGhlcmUgYW55IHNvbHV0aW9u
IGZvciB0aGlzPwo+CgpXaGF0IGVuY29kaW5nIHNjaGVtZSBkaWQgeW91IHVzZT8KU2hvdyBtZSB0
aGUgY29udGVudCBvZiBFbGVtZW50LnRleHQuCgotLQpodHRwOi8vbm9obWFkLnN1Yi1wb3J0Lm5l
dAo=
 
T

TAKANO Noriyuki

Gyoung-Yoon Noh said:
What encoding scheme did you use?
Show me the content of Element.text.
Dear Yoon,

Noh might have already helped you out and my suggestion here may not be
relevant, but I wonder what method, e.g. puts, print or p, you used to
print the return of element.text. The element.text method only returns
text data but doesn't print. (You can see something on the console if
you are using something interactive, but it may not appear as the string
you expected.)

Have you tried like these lines?
$stdout.puts element.text
and
$stdout.puts element.to_s
The $stdout.puts method shows the character string obtained from the
object (the return value of element.text or element.to_s in the cases
above).
Some others like
p element.text
may not show the string you expected, but it does show a representation
of the object which is not necessarily a character string.

cheers,
nori
 
H

hongseok.yoon

I think it may be a problem of REXML.
If I print [element].to_s, the string is already broken.

Are there another XML library for RUBY?
 
G

Gyoung-Yoon Noh

T24gMi8yMy8wNiwgaG9uZ3Nlb2sueW9vbkBnbWFpbC5jb20gPGhvbmdzZW9rLnlvb25AZ21haWwu
Y29tPiB3cm90ZToKPiBJIHRoaW5rIGl0IG1heSBiZSBhIHByb2JsZW0gb2YgUkVYTUwuCj4gSWYg
SSBwcmludCBbZWxlbWVudF0udG9fcywgdGhlIHN0cmluZyBpcyBhbHJlYWR5IGJyb2tlbi4KPgo+
IEFyZSB0aGVyZSBhbm90aGVyIFhNTCBsaWJyYXJ5IGZvciBSVUJZPwo+Cj4KPgoKV2hhdCBkaWQg
dGhleSBsb29rIGxpa2U/IFNob3cgdGhlIHJlc3VsdCBvZiAicCBlbGVtZW50IiwgZm9yIGV4YW1w
bGU6CgppcmIobWFpbik6MDExOjA+IHB1dHMgSWNvbnYuaWNvbnYoJ3V0Zi04JywgJ2V1Yy1rcics
ICJcMjY3XDM0N1wyNzJcMzYxIikuZmlyc3QK54y34pGk7YmsCj0+IG5pbAppcmIobWFpbik6MDEy
OjA+IHAgSWNvbnYuaWNvbnYoJ3V0Zi04JywgJ2V1Yy1rcicsICJcMjY3XDM0N1wyNzJcMzYxIiku
Zmlyc3QKIlwzNTNcMjQzXDI1MFwzNTNcMjcxXDIwNCIKPT4gbmlsCgpBbnlvbmUgd2hvIHdpbGxp
bmcgdG8gcmVwbHkgeW91ciBxdWVzdGlvbiwgbmVlZCB0byBzZWUgdGhlCmludGVybmFsIHJlcHJl
c2VudGF0aW9uIG9mIHRoZSBicm9rZW4gc3RyaW5ncyBsaWtlIGxhdHRlciBmb3JtLgpBY3R1YWxs
eSwgdGhhdCdzIG5vdCBicm9rZW4uIERvbid0IGxvc2UgaG9wZS4gOikKCi0tCmh0dHA6Ly9ub2ht
YWQuc3ViLXBvcnQubmV0Cg==
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,202
Messages
2,571,057
Members
47,665
Latest member
salkete

Latest Threads

Top