From: Tachikoma Date: 2008-07-22T21:09:30+09:00 Subject: Re: Source code to XML On Jul 22, 6:17 pm, Tommy Nordgren wrote: > I need to generate DocBook ProgramListing xincludes from a source code   > file. > How can I escape characters that is not valid in text : < > " & > > ------------------------------------- > This sig is dedicated to the advancement of Nuclear Power > Tommy Nordgren > tommy.nordg...@comhem.se require 'rexml/text' REXML::Text.normalize("Some & text < foo > \" bar") ==> "Some & text < foo > " bar" i think this may help you