Source code to XML

Discussion in 'Ruby' started by Tommy Nordgren, Jul 22, 2008.

  1. 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, Jul 22, 2008
    #1
    1. Advertising

  2. Tommy Nordgren

    Tachikoma Guest

    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
    >


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

    i think this may help you
    Tachikoma, Jul 22, 2008
    #2
    1. Advertising

  3. Tommy Nordgren

    Tachikoma Guest

    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
    >


    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
    Tachikoma, Jul 22, 2008
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. melledge
    Replies:
    0
    Views:
    360
    melledge
    Aug 9, 2005
  2. Author Tarun Tyagi
    Replies:
    0
    Views:
    710
    Author Tarun Tyagi
    Dec 29, 2004
  3. Jens-Oliver Murer
    Replies:
    1
    Views:
    457
    Jens-Oliver Murer
    Oct 17, 2008
  4. Jenny
    Replies:
    3
    Views:
    257
    Dag Sunde
    Dec 17, 2004
  5. Erik Wasser
    Replies:
    5
    Views:
    450
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page