S
Salim Reza
Hi,
I am very new to ruby programming and therefore, facing problem in xml
parsing in ruby. 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), rubyfile(my try). Can you please
help me in writing ruby code that generates output as shown above from
xmlfile.
Thanks in advance.
Regards,
Salim
Attachments:
http://www.ruby-forum.com/attachment/5558/xmlfile.xml
http://www.ruby-forum.com/attachment/5559/rubyfile.rb
I am very new to ruby programming and therefore, facing problem in xml
parsing in ruby. 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), rubyfile(my try). Can you please
help me in writing ruby code that generates output as shown above from
xmlfile.
Thanks in advance.
Regards,
Salim
Attachments:
http://www.ruby-forum.com/attachment/5558/xmlfile.xml
http://www.ruby-forum.com/attachment/5559/rubyfile.rb