On Wed, Nov 3, 2010 at 7:27 AM, Mike Dalessio <[email protected]>wrote:
> > Take a deep breath. I believe you are quoting your strings > incorrectly. Witness the following script, which behaves as expected > on Nokogiri 1.4.3.1 and libxml 2.7.6: > > require 'rubygems' > require 'nokogiri' > > xml = '<root><foo _SSN="a2/PP00nFwWa7I8Jog7bcw==\n">bar</foo></ > root>' > > puts Nokogiri::XML.parse(xml).to_xml > # => <?xml version="1.0"?> > # <root> > # <foo _SSN="a2/PP00nFwWa7I8Jog7bcw==\n">bar</foo> > # </root> > > Next time you may want to try the nokogiri-talk mailing list for a > quicker response from users of the library. > Thanks Mike, this does work when I try it in the console and you are right, has to do with quoting. What seems clear is that the entire xml has to be within single quotes, as if it is within double quotes then the \n gets replaced. What I am not clear about is how to tell Ruby when I load the file (I am getting the xml out of a saved file), to put it in single rather than double quotes? Or is there a way to transform it after loading it. When I am reading the file in I get: file = "<BORROWER _SSN=\"a2/PP00nFwWa7I8Jog7bcw==\n\"></BORROWER>" > > -- > You received this message because you are subscribed to the Google Groups > "Ruby on Rails: Talk" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]<rubyonrails-talk%[email protected]> > . > For more options, visit this group at > http://groups.google.com/group/rubyonrails-talk?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

