xml parsing in ruby

S

Saleem Vighio

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,581
Members
45,056
Latest member
GlycogenSupporthealth

Latest Threads

Top