Forum: Ruby inserting raw xml into a rexml document

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
ara.t.howard (Guest)
on 2005-12-11 07:03
(Received via mailing list)
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
ruby-ml (Guest)
on 2005-12-11 08:43
(Received via mailing list)
On 2005.12.11 14:00, "Ara.T.Howard" <removed_email_address@domain.invalid> 
wrote:
>    => "&lt;foobar&gt;"
> __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
ara.t.howard (Guest)
on 2005-12-11 09:19
(Received via mailing list)
On Sun, 11 Dec 2005, Eero S. wrote:

> 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
This topic is locked and can not be replied to.