From: Robert Klemme Date: 2008-10-22T18:16:08+09:00 Subject: Re: rexml create a tag with literal characters 2008/10/22 Onno Faber : > I'm having a problem finding out how to parse literal characters into a > new tag using rexml. I'm creating an excel xml document using rexml: > xml.instruct! :xml, :version=>"1.0", :encoding=>"UTF-8" > > In the document, I'm creating a "Data" tag, and parsing the content of > the variable "content_line" in it: > xml.Data content_line, 'ss:Type' => 'String' > > The thing is that the data in "content_line" contains simple tags like > and . I want to preserve this, as excel can read these > tags out and format the document. However, the output is as follows: > <u> > > Is there any way I can prevent this encoding from happening? So far I > was not able to find the answer. XML parse the string yourself and add those nodes to the document. Example: require 'rexml/document' # create the doc master = REXML::Document.new("") puts master # find the node - either way root = master[1] root = master.elements['//root'] # parse the sub tree sub = REXML::Document.new "test data" # add the subtree root.add sub # see what we got puts master Kind regards robert -- remember.guy do |as, often| as.you_can - without end