Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Ruby > Extract values from Hash map

Reply
Thread Tools

Extract values from Hash map

 
 
Naresh Ramaswamy
Guest
Posts: n/a
 
      02-16-2009
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:(E-Mail Removed)", "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:(E-Mail Removed)' />
<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:(E-Mail Removed)" and so on..,

Thanks,
Naresh
--
Posted via http://www.ruby-forum.com/.

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hash of hash of hash of hash in c++ rp C++ 1 11-10-2011 04:45 PM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
how to put the content of one hash map to another hash map navS C++ 3 05-09-2008 12:52 PM
STL map or hash map using struct as data and find it kl C++ 7 01-01-2008 11:05 AM
Hash Map slower than Map. Amit Bhatia C++ 7 10-09-2007 09:33 AM



Advertisments