J
Jesse P.
Hi all,
Im working with some UTF-8 data and basically if I run this:
require 'rexml/document'
data = "<name>\302</name>"
doc = REXML:ocument.new(data)
I get an error that says I did not close the <name> tag:
REXML:arseException: #<REXML:arseException: No close tag for
["name"]>
/usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:26:in `parse'
/usr/lib/ruby/1.8/rexml/document.rb:190:in `build'
/usr/lib/ruby/1.8/rexml/document.rb:45:in `initialize'
(irb):48:in `new'
(irb):48:in `irb_binding'
/usr/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding'
/usr/lib/ruby/1.8/irb/workspace.rb:52
....
No close tag for ["name"]
Line:
Position:
Last 80 unconsumed characters:
from /usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:89:in
`parse'
from /usr/lib/ruby/1.8/rexml/document.rb:190:in `build'
from /usr/lib/ruby/1.8/rexml/document.rb:45:in `initialize'
from (irb):48:in `new'
from (irb):48
The code only works if I use single quotes instead,
i.e.
doc = REXML:ocument.new('<name>\302</name>')
But since data is a variable, I cant simply declare it with single
quotes.
Any ideas why REXML:ocument doesnt parse properly? Or perhaps is
there a way around this? Maybe I can convert to some other character
encoding to avoid the problem...
Best regards,
Jesse
Im working with some UTF-8 data and basically if I run this:
require 'rexml/document'
data = "<name>\302</name>"
doc = REXML:ocument.new(data)
I get an error that says I did not close the <name> tag:
REXML:arseException: #<REXML:arseException: No close tag for
["name"]>
/usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:26:in `parse'
/usr/lib/ruby/1.8/rexml/document.rb:190:in `build'
/usr/lib/ruby/1.8/rexml/document.rb:45:in `initialize'
(irb):48:in `new'
(irb):48:in `irb_binding'
/usr/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding'
/usr/lib/ruby/1.8/irb/workspace.rb:52
....
No close tag for ["name"]
Line:
Position:
Last 80 unconsumed characters:
from /usr/lib/ruby/1.8/rexml/parsers/treeparser.rb:89:in
`parse'
from /usr/lib/ruby/1.8/rexml/document.rb:190:in `build'
from /usr/lib/ruby/1.8/rexml/document.rb:45:in `initialize'
from (irb):48:in `new'
from (irb):48
The code only works if I use single quotes instead,
i.e.
doc = REXML:ocument.new('<name>\302</name>')
But since data is a variable, I cant simply declare it with single
quotes.
Any ideas why REXML:ocument doesnt parse properly? Or perhaps is
there a way around this? Maybe I can convert to some other character
encoding to avoid the problem...
Best regards,
Jesse