xml parsing in ruby

Discussion in 'Ruby' started by Saleem Vighio, Dec 15, 2010.

  1. Hi,

    I am very new to ruby language and have problem in xml parsing in ruby.
    Please help. The problem is to parse an xml file(xmlfile.xml) in ruby
    that should generate a code which should look like as under:

    <declaration>typedef int[0,2] StateTC;
    const StateTC TC_ACTIVE = 0;
    const StateTC TC_COMPLETING = 1;
    const StateTC TC_ENDED = 2;

    StateTC stTC = TC_ACTIVE;

    typedef int[0,2] StateP;
    const StateP P_ACTIVE = 0;
    const StateP P_COMPLETING = 1;
    const StateP P_ENDED = 2;

    StateP stP = P_ACTIVE;

    typedef int[0,1] MsgsTC;
    const MsgsTC PREPARE_TC = 0;
    bool msgsTc[MsgsTC];

    typedef int[0,1] MsgsP;
    const MsgsP COMPLETE_P = 0;
    bool msgsP[MsgsP];

    </declaration>

    I attach 2 files: xmlfile(source file), and rubyfile(my try) . Can you
    please help me in writing ruby code that generates output as shown above
    from xmlfile.

    Thanks in advance.

    Regards,
    Saleem

    Attachments:
    http://www.ruby-forum.com/attachment/5555/xmlfile.xml
    http://www.ruby-forum.com/attachment/5556/rubyfile.rb


    --
    Posted via http://www.ruby-forum.com/.
     
    Saleem Vighio, Dec 15, 2010
    #1
    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. Per Magnus L?vold
    Replies:
    0
    Views:
    1,439
    Per Magnus L?vold
    Nov 15, 2004
  2. Greg Wogan-Browne
    Replies:
    1
    Views:
    884
    Uche Ogbuji
    Jan 28, 2005
  3. Replies:
    2
    Views:
    517
  4. John Levine
    Replies:
    0
    Views:
    767
    John Levine
    Feb 2, 2012
  5. Erik Wasser
    Replies:
    5
    Views:
    530
    Peter J. Holzer
    Mar 5, 2006
Loading...

Share This Page