Forum: Ruby Extract values from Hash map

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
78d0dd514b51f54aa016c3d3032ba011?d=identicon&s=25 Naresh Ramaswamy (s2naresh)
on 2009-02-16 07:09
Following is my code wherein I am reading from an XML file

******************************************
require 'xmlconfigfile'

data = XmlConfigFile.new('script_data.xml')

data.no_hash_key_element_path = true
data.expand_attributes = true
senddata =
data.get_parameters("/TEST_SCRIPT/TXN[@value='1']/SEND[@request='INVITE']/*")

p senddata

*****************OUTPUT is as follows******************

{"MODIFY_2.uri"=>"tel:naresh@span.com", "MODIFY_1"=>nil,
"MODIFY_3.mname"=>"REGister", "MODIFY_3.header"=>"req_line",
"MODIFY_2"=>nil, "MODIFY_3"=>nil, "MODIFY_1.header"=>"from",
"REMOVE.header"=>"call_id", "MODIFY_2.mname"=>"InVIte",
"MODIFY_1.tag"=>"12345", "MODIFY_2.header"=>"req_line", "REMOVE"=>nil}

*********script_data.xml(XML File) is as follows***************

<TEST_SCRIPT>
<TXN value = '1'>
  <SEND request = 'INVITE'>
    <MODIFY_1 header = 'from'  tag='12345'/>
    <MODIFY_2 header = 'req_line' mname = 'InVIte' uri =
'tel:naresh@test.com' />
    <MODIFY_3 header = 'req_line' mname = 'REGister'  />
    <REMOVE header = 'call_id' />
  </SEND>
</TXN>
******************************************

Query:
How can I get the hash values such that when I call "MODIFY_2.uri" it
must return "tel:naresh@span.com" and so on..,

Thanks,
Naresh
This topic is locked and can not be replied to.