Source code to XML

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.nordgren@comhem.se

require 'rexml/text'
REXML::Text.normalize("Some & text < foo > \" bar")
==> "Some &amp; text &lt; foo &gt; &quot; bar"

i think this may help you

···

On Jul 22, 6:17 pm, Tommy Nordgren <tommy.nordg...@comhem.se> 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

irb(main):020:0> require 'rexml/text'
=> true
irb(main):021:0> REXML::Text.normalize("Some & text < foo > \" bar")
=> "Some &amp; text &lt; foo &gt; &quot; bar"

this may help

···

On Jul 22, 6:17 pm, Tommy Nordgren <tommy.nordg...@comhem.se> 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