inserting raw xml into a rexml document

A

Ara.T.Howard

how can i do this:


[ahoward@localhost xhtml-0.0.0]$ irb -r rexml/document
irb(main):001:0> REXML::Text::new("<foobar>", respect_whitespace=false, parent=nil, raw=false).to_s
=> "&lt;foobar&gt;"

irb(main):002:0> REXML::Text::new("<foobar>", respect_whitespace=false, parent=nil, raw=nil).to_s
=> "&lt;foobar&gt;"

irb(main):003:0> REXML::Text::new("<foobar>", respect_whitespace=false, parent=nil, raw=true).to_s
/usr/local/lib/ruby/1.8/rexml/text.rb:90:in `initialize': Illegal character '<' in raw string "<foobar>" (Exception)
from (irb):3:in `new'
from (irb):3:in `irb_binding'
from /usr/local/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding'
from /usr/local/lib/ruby/1.8/irb/workspace.rb:52


is there no way to subvert the call to allow placing raw strings containing
__any__ chars into the output?

regards.

-a
--
===============================================================================
| ara [dot] t [dot] howard [at] noaa [dot] gov
| all happiness comes from the desire for others to be happy. all misery
| comes from the desire for oneself to be happy.
| -- bodhicaryavatara
===============================================================================
 
E

Eero Saynatkari

how can i do this:


[ahoward@localhost xhtml-0.0.0]$ irb -r rexml/document
irb(main):001:0> REXML::Text::new("<foobar>", respect_whitespace=false, parent=nil, raw=false).to_s
=> "&lt;foobar&gt;"

irb(main):002:0> REXML::Text::new("<foobar>", respect_whitespace=false, parent=nil, raw=nil).to_s
=> "&lt;foobar&gt;"

irb(main):003:0> REXML::Text::new("<foobar>", respect_whitespace=false, parent=nil, raw=true).to_s
/usr/local/lib/ruby/1.8/rexml/text.rb:90:in `initialize': Illegal character '<' in raw string "<foobar>" (Exception)
from (irb):3:in `new'
from (irb):3:in `irb_binding'
from /usr/local/lib/ruby/1.8/irb/workspace.rb:52:in `irb_binding'
from /usr/local/lib/ruby/1.8/irb/workspace.rb:52


is there no way to subvert the call to allow placing raw strings containing
__any__ chars into the output?

Are you actually trying to create new elements in the doc? (If not, then
the entity conversion is the correct behaviour.) If you want to insert
elements, the simplest way is probably to just create a new document
from the string and then insert that as a child of your current
element.
regards.

-a

E
 
A

ara.t.howard

Are you actually trying to create new elements in the doc? (If not, then the
entity conversion is the correct behaviour.) If you want to insert elements,
the simplest way is probably to just create a new document from the string
and then insert that as a child of your current element.

that's just what i did! thanks!

-a
--
===============================================================================
| ara [dot] t [dot] howard [at] noaa [dot] gov
| all happiness comes from the desire for others to be happy. all misery
| comes from the desire for oneself to be happy.
| -- bodhicaryavatara
===============================================================================
 

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

Staff online

Members online

Forum statistics

Threads
473,755
Messages
2,569,534
Members
45,007
Latest member
obedient dusk

Latest Threads

Top